This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes PROBLEMS WITH APPLET -> SERVLET communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "PROBLEMS WITH APPLET -> SERVLET communication" Watch "PROBLEMS WITH APPLET -> SERVLET communication" New topic
Author

PROBLEMS WITH APPLET -> SERVLET communication

Namara Krein
Greenhorn

Joined: May 22, 2006
Posts: 7
Hello!!

I think I have a problem with applet -> servlet communication. I need write in ObjectOutputStream some info and then, my servlet must read this info. The problem is that servlet read but then, when it must go to another jsp, it doesn�t.

Applet Code:

private URLConnection getServletConnection() throws MalformedURLException, IOException {
URL urlServlet = new URL("http","localhost",8080,"/project/ReadStatisticsAction.do");
URLConnection con = urlServlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type","application/x-java-serialized-object");
return con;
}
public void doSend() {
try {
URLConnection con = getServletConnection();

OutputStream out=con.getOutputStream();
ObjectOutputStream toServlet = new ObjectOutputStream(out);
toServlet.writeObject(cScene.getStatistics());
toServlet.flush();
toServlet.close();

InputStream instr = con.getInputStream();
instr.close();

} catch (Exception e) {
e.printStackTrace();
}
}

Servlet Code:

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
try {
InputStream oin=request.getInputStream();
ObjectInputStream fromApplet=new ObjectInputStream(oin);
HashMap statistics=(HashMap)fromApplet.readObject();
fromApplet.close();

request.getSession().setAttribute("statistics",statistics);

return mapping.findForward("success");
} catch (Exception e) {
return mapping.findForward("login-error");
}
}


Thanks in advance for your help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
Since you say that the servlet reads the info fine, this question is not really about applet/servlet communication, but about setting up Struts so that it forwards correctly. I'll move the question to the Struts forum; please find it there and continue the discussion.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PROBLEMS WITH APPLET -> SERVLET communication
 
Similar Threads
Issues regarding Applet-Servlet communication
Swing - servlet communication
Communication between Servlet and Applet
Signed applet talking to server other than its own
Applet Servlet Connection & Communication