This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Applet to Servlet communication

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following method write an object to Servlet.
It works 95% of time but hangs at "InputStream stream = con.getInputStream(); " sometimes.
I had put log message in servlet and when it hangs I am not getting anything in the servlet. I had made sure that all the streams are closed properly...
Any help is appreciated!!
Problem seems to be appearing only with netscape browser!!
//Following is the code example (Applet Side).
public InputStream sendPostMessage(Serializable obj) throws IOException
{
URLConnection con = servletUrl.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "java-internal/" + obj.getClass().getName());
ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream());
out.writeObject(obj);
out.flush();
out.close();
System.out.println("before getting stream");
InputStream stream = con.getInputStream();
//When is hangs it does not come here, means waits indefinately in above line......
System.out.println("Got the stream");
return stream;
}
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!