• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Applet - Servlet Communication  RSS feed

Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing my first program for performing applet-servlet communication, and no matter what I try, I have not been able to run it. I know my servlet is fine, 'coz i can get the results if i give it's url directly in the browser. I'm trying to implement an (only) applet-servlet example in the book: Professional Java Server programming, chapter 11. I've even used some sort of applet coverter plug-in, which the book suggests to use in case of error.
The error i'm getting is : java.io.FileNotFoundException, and then it says, it can't find the servlet, although the servlet IS initialized !!. I think it has something to do with the security.
I'm using DataOutputStream to send an SQL query to the servlet, and then using InputStreamReader to read the results, which servlets writer onto the PrintWriter obtained from the request object.
Can somebody help me?
Thanks a lot in advance,
Posts: 22877
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check www.javaranch.com/common.html and look for ObjectServlet.java and HTTP.java
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to use the class com.javaranch.common.Http for a similar problem (Applet to Servlet communication). I can read from the servlet. However when I try to write to it, I also get "FileNotFoundException" excpetion. My Applet code to send an object to the servlet is as follow:
URL myurl = new URL(getCodeBase(), "/servlet/SimpleServlet");
URLConnection con = myurl.openConnection();
con.setUseCaches( false );
Object obj = new String(fname);
ObjectOutputStream out = new ObjectOutputStream( new GZIPOutputStream( con.getOutputStream() ) );
if ( obj != null )
out.writeObject( obj );
Any help or idea is appreciated.
Arsalan Madjd

Posts: 20129
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What line in your sample code throws the exception?
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!