DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    35

    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());
    toApplet.writeObject(jspCustomer);

    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
    Location
    Ireland
    Posts
    35
    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

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links