I find the jsp code for send socket, and change the IP to 255.255.255.255, but the result is it says: 'Network is unreachable
'.
The code is:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.util.*,java.net.*,java.io.*,java.lang.*" errorPage="" %>
var errors="";
<%
try{
int character;
Socket socket = new Socket("255.255.255.255", 10000);
InputStream inSocket = socket.getInputStream();
OutputStream outSocket = socket.getOutputStream();
String str = "Message";
byte buffer[] = str.getBytes();
outSocket.write(buffer);
while ((character = inSocket.read()) != -1) {
out.print((char) character);
}
socket.close();
}
catch(java.lang.Exception e){
%>
errors="Something is wrong!"+ "<%= e.getMessage() %>";
<%
}
My tomcat is version 6( I guess...),
Or if it's impossible( I heard people say jsp is different from java, it only use for presentation), can I write a java class( using DatagramSocket) to show the receiving data and let my jsp import the class and get the data?
Any advice will be appreciated.