I building web application program using Netbeans 7.4 by creating jApplet file that communicate with servlet by Serializable object. Servlet file will communicate with DB and send results to applet and also applet has to use the Serializable object to send and receive data from servlet. I actually created both servlet and JApplet files under the source folder directory. The error is I ma not getting any communication between JApplet and servlet, and keeps giving me "protocol doesn't support output". Here is my Applet code that connecting to servlet:
myObject = new ExpertDataObject();
((ExpertDataObject) myObject).setSession("EnterUser");
((ExpertDataObject) myObject).setUser(userText.getText());
((ExpertDataObject) myObject).setPassword(passText.getText());
URL currentPage = getCodeBase();
System.out.println(currentPage);
String urlSuffix = "Server";
URL urlServlet = new URL(getCodeBase(), "Server");
System.out.println(urlServlet);
URLConnection con = urlServlet.openConnection();
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestProperty("Content-Type", "application/x-java-serialized-object");
myOutputStream = new ObjectOutputStream(con.getOutputStream());
myInputStream = new ObjectInputStream(con.getInputStream());
myOutputStream.writeObject(myObject);
myObject = (DataObject) myInputStream.readObject();
if (myObject.getMessage().equals("success")) {
dateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
....
Can anyone help me showing the steps of creating jApplet communicating with servlet +mySQL as web application in Netbeans.
Thanks in advance
Arwa
Here is what I found in Server log Feb 12, 2014 11:53:23 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [Server] in context with path [/ExpertToolAppletServlet2] threw exception java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2325) at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2794) at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:801) at java.io.ObjectInputStream.(ObjectInputStream.java:299) at Server.processRequest(Server.java:73) at Server.doGet(Server.java:177) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
And here is here is my servlet code under processRequest
String contentType = "application/x-java-serialized-object";
response.setContentType(contentType);
InputStream inputStream = request.getInputStream();
ObjectInputStream in = new ObjectInputStream(inputStream);
myObject = (DataObject) in.readObject();
String process= ((ExpertDataObject) myObject).getSession();
System.out.println(urlServlet);?file:/protocol does not allow writing. Read further here: stackoverflow.com/questions/4975743/…500 - Internal Server Errorlook into the server log for the cause.