Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet to servlet communication-- Urgent

 
venkat
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends i need ur help.
I want to send object from the applet to the servlet. Here im pasting the code and im finding problem while transferring the data .. Im getting java.io.InterruptedIOException while reading the data in the servlet.Please help me to resolve the problem..

Code in the applet:
try{
AppletContext ac = this.getAppletContext();
URL dataDBservlet = new URL(this.getCodeBase(),"/servlet/CallServlet");
URLConnection servletConnection = dataDBservlet.openConnection();
servletConnection.setUseCaches(false);
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setRequestProperty ("Content-Type", "application/octet-stream");
ObjectOutputStream oos = new ObjectOutputStream (servletConnection.getOutputStream());
Vector vc = new Vector();
vc.addElement(timeSheetData);
oos.writeObject(vc);
ac.showDocument(dataDBservlet);
oos.flush();
oos.close();
}catch(Exception e){
System.out.println("Error in capplet.java "+e);
}
Im not facing any problem here.Its calling the servlet.

Servlet Code:
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException{
res.setContentType("application/octet-stream");
PrintWriter out = res.getWriter();
System.out.println("stage 1:");
Vector v = new Vector();
inputFromApplet = new ObjectInputStream ( req.getInputStream());
System.out.println("stage 2:");
v = (Vector) inputFromApplet.readObject();
inputFromApplet.close();
}catch(InterruptedIOException iex){
System.out.println("Error in Call servlet :"+iex);
}catch(Exception e){
System.out.println("Error in CallServlet "+e);
}
Here im getting output in webserver Stage :1
and printing java.io.InterruptedIOException

Please put ur ideas and send me as soon as posible.

venkat
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"venkat",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic