DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006

    jsp to applet communication

    Hi can anybody help me with this jsp/servlet/applet communication problem.
    I have a variable of type Customer in a jsp page and I want to send the Customer object to an applet on the same page.
    I have been told the only way to do this is via a servlet.
    So in the jsp page I put the Customer object named myCustomer in the session...

    <%session.putValue("c", myCustomer);%>

    and I am now able to get the customer object in the doGet method of the servlet...

    Session s = req.getSession();
    Customer jspCustomer = (Customer) s.getAttribute("c");

    OK, everything works so far. I can use all the public methods of Customer within my servlet.

    My problems start when I try to send my Customer object to the applet over a http connection (I have imported all the relevent libraries into the servlet)

    ObjectOutputStream toApplet = new ObjectOutputStream(res.getOutputStream());

    When I load my jsp page the applet doesn't work.

    The interesting thing about this problem is that if I make a Customer instance within the servlet and send this instance to the applet it works fine.
    Surely my jspCustomer should behave exactly like a Customer instantiated within the servlet? If I can send one object to the applet then I should be able to send either.

    Any help on this is much appreciated. Or if you think I am going in the completely wrong direction I'm interested in alternative approaches.

  2. #2
    Join Date
    Jan 2006
    I've just solved my own problem. Bit of a silly mistake. My Customer object holds an array of Product objects. Although I implemented serializable for Customer I forgot to make Product serislizable. Everything works now.

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2007, 05:58 PM
  2. Replies: 3
    Last Post: 08-23-2001, 11:01 AM
  3. JSP - Applet communication
    By Jo Desmet in forum authorevents.pekowsky
    Replies: 1
    Last Post: 08-14-2000, 08:58 PM
  4. Replies: 1
    Last Post: 08-10-2000, 12:35 PM
  5. Replies: 1
    Last Post: 08-10-2000, 12:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.