Bonjour Toute Le Monde
Comment Executer Une Classe Java Dans Une Page Jsp
:ccool:
Version imprimable
Bonjour Toute Le Monde
Comment Executer Une Classe Java Dans Une Page Jsp
:ccool:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pack1; import java.net.InetAddress; public class Ping { public static String main(String[] args) throws Exception { InetAddress address = InetAddress.getByName("127.0.0.1"); boolean etat = address.isReachable(10000); return ("Connection Etablie " + etat); //InetAddress address = InetAddress.getByName("web.mit.edu"); //return("Name: " + address.getHostName()); //return("Addr: " + address.getHostAddress()); //return("Connection Etablie: " + address.isReachable(3000)); } }
Ce code ne donne pas le résultat de la page Java.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="pack1.Ping"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Ping</title> </head> <body> <h2> <% Ping p = new Ping(); out.print(p); %> </h2> </body> </html>
change ta classe par ça et cela devrait aller un tout petit peu mieux ;)
Code:
1
2
3
4
5
6
7
8
9
10 public class Ping { public String toString() throws Exception { InetAddress address = InetAddress.getByName("127.0.0.1"); boolean etat = address.isReachable(10000); return "Connection Etablie " + etat; } }