Hi list,

I'm new to servlets, and I'm at an impasse. I am trying a proof-of-concept for what I thought would be a very simple process of an applet passing a serialized object to a servlet, and the servlet sending a serialized object as the response. I've tried Tomcat 4.1.30 and 5.0.27 with identical results. I keep getting a FileNotFoundException when the applet tries to get the servlet's output stream to read back the result object. And if I've set up logging for the servlet correctly, there's no evidence that the servlet is ever invoked. Here's some code, and I'm hoping that some of the experts here can point to an obvious error that I've committed. I've done my due diligence and I didn't find this error on the list, but found one other reference to someone with the exact same problem from the year 2002, but there was no reply to him posted there.

Thanks to any and all,

Don

Applet snippet:

try {
URL intelxServlet = new URL("http://localhost:8080/intelx/servlet/LexerServlet";);
URLConnection servletConnection = intelxServlet.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectOutputStream outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());


String textXML = "abcdefg";
outputToServlet.writeObject(textXML);
outputToServlet.flush();
outputToServlet.close();


/* FileNotFoundException thrown before this call completes */
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
String reply = (String) inputFromServlet.readObject();


       return 0;
   }
   catch(Exception e) {
       e.printStackTrace();
       return 1;
   }

Servlet snippet:

public class LexerServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/x-java-serialized-object");


try {
ObjectInputStream inputFromApplet = new ObjectInputStream(request.getInputStream());
String textXML = (String) inputFromApplet.readObject();
inputFromApplet.close(); ObjectOutputStream outputToApplet = new ObjectOutputStream(response.getOutputStream());
outputToApplet.writeObject(textXML+"12345678"); // prove that we got the data
outputToApplet.flush();
outputToApplet.close();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to