TomCat won't receive Applet POST'ed info to servlet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Terence_Bower
Posted On:   Thursday, December 6, 2001 10:35 PM

I was using iPlanet to test Applet and Servlet communication and everything worked fine. I installed TomCat (I am testing for a client who will not have iPlanet). The same code will not work, the servlet is found okay, but there is nothing in the query string.





I have tried all kinds of solutions, and none work.






I am desperate for an answer ASAP!!

Re: TomCat won't receive Applet POST'ed info to servlet

Posted By:   Shiva_dacherla  
Posted On:   Wednesday, December 26, 2001 09:24 AM

I don't know what is the existing code in your applet. I have the working code in Applet with Tomcat as follows.


servletGET="https://" + hostName + ":" + port + servletPath;

URL url = new URL( servletGET );


URLConnection servletConnection = url.openConnection();


servletConnection.setDoInput(true);

servletConnection.setDoOutput(true);

servletConnection.setRequestProperty("Content-Type", "application/octet-stream");


// Don't use a cached version of URL connection.

servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);


outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
outputToServlet.writeObject(groupHostList);



outputToServlet.flush();
outputToServlet.close();


Object object = readServletResponse(servletConnection);


The method readServletResponse..
/**
* Reads a response from the servlet.
*/
private Object readServletResponse(URLConnection servletConnection){
Object object = null;
ObjectInputStream inputFromServlet = null;
try{
inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
object = inputFromServlet.readObject();
inputFromServlet.close();

}catch (Exception e){
log(e.toString());
return null;
}

return object;
}



Regards,


Shiva

About | Sitemap | Contact