• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IOexception in Applet-servlet communication

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there,
I want my applet to communicate with a servlet. and hence I use URLConnection and the corresponding IOStreams for that. But a IOException is getting raised.
THe Code is as follows
URL url = new URL("http://10.10.1.78:8080/servlet/SysServer");
String qry = URLEncoder.encode("qry") + "=" + URLEncoder.encode(qryString);
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-type","application/x-www-form-urlencoded");
DataOutputStream dos = new DataOutputStream(uc.getOutputStream());
dos.writeBytes(qry);
dos.flush();<----Here
dos.close();
ObjectInputStream oin = new ObjectInputStream(uc.getInputStream());<---Here
AN IOException is getting raised. at the lines pointed cby "<----Here". The puzzling thing is that the Exception is getting raised at out.flush() and not at the creation of the ouputstream. and I comment the Flush() line ,it is thrown at
uc.getInputStream().
What is the Possible cause
Please act fast

Zafer
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen this when the server wasn't available for some reason. Try and code an html page to do the post to the server. Work on getting the server running properly with this, then try your code. I don't see any thing wrong with it. However if the server is available and you still get this, let me know and include the qryString.
Hope this helps
 
mohamed zafer
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Carl,
I tried your solutoin ,but it was giving the same exception.
When I tried creating the URL using getPort() and getHost(), I found that the applet is in port 80 while the server is in port 8080. I could'nt sort out the reason for the differences in port number. THen I tried copying and modifying the phone example from the JavawebServer, and it worked fine. Now I am continueing with that and it is working fine
Thank you ponce again and let me know if you come to know the reason.
Zafer
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic