Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Applet Servlet Communication

Posted on 2009-05-04
6
Medium Priority
?
556 Views
Last Modified: 2013-11-23
I am sending HashMap from Applet to Servlet but when the servlet tries to read the input stream of the request object using the following code :-
              InputStream in = request.getInputStream();
              ObjectInputStream inputFromApplet = new ObjectInputStream(in);
It throws an exception java.io.EOFException.
Any idea what is going wrong here .
0
Comment
Question by:jdpositive
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24300286
how is the servlet sending it?

0
 
LVL 92

Expert Comment

by:objects
ID: 24300309
(meant applet)
0
 

Author Comment

by:jdpositive
ID: 24300350
Pasting the code snippet :-
a)Applet
      urlServlet = new URL("http://tools-dev.cisco.com/support/downloads/dlcws/DownloadManagerServlet");
   conn = urlServlet.openConnection();
   conn.setDoInput(true);
   conn.setDoOutput(true);
   conn.setUseCaches(false);
   conn.setRequestProperty("Content-Type","application/x-java-serialized-object");
   
   //Send object to the servlet
   HashMap inputParametersMap = new HashMap();
   inputParametersMap.put("userId", userId);
   inputParametersMap.put("cartId", cartId);
   
   OutputStream outstream = conn.getOutputStream();
   ObjectOutputStream oos = new ObjectOutputStream(outstream);
   oos.writeObject(inputParametersMap);
   oos.flush();
   oos.close();
b)Servlet

   String userId = null;
   String cartId = null;
   String operation = null;
   ArrayList cartList = new ArrayList();
   OutputStream outstr = response.getOutputStream();
   ObjectOutputStream oos = new ObjectOutputStream(outstr);
 
   try
   {
    response.setContentType("application/x-java-serialized-object");
    //read a String-object from applet
    // instead of a String-object, you can transmit any object, which
    // is known to the servlet and to the applet
    InputStream in = request.getInputStream();
    ObjectInputStream inputFromApplet = new ObjectInputStream(in); //Throws Exception here
    HashMap inputParametersMap = (HashMap) inputFromApplet.readObject();
0
 
LVL 92

Expert Comment

by:objects
ID: 24300963
can't see a problem there, as a test try removing:

   OutputStream outstr = response.getOutputStream();
   ObjectOutputStream oos = new ObjectOutputStream(outstr);


0
 

Accepted Solution

by:
jdpositive earned 0 total points
ID: 24301111
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question