• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

passing a Vector from JSP to an applet

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to pass a Vector from JSP to an applet? If so how? Thanks in advance.
Scott
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, you can pass Vector thru the applet tag using scriplet to iterate through the Vector elements as applet parameters. Or you can send the Vector as a stream and open a URLConnection in applet. But this only works for elements that are String.
Maybe someone can help.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You can pass it as a serialized object from JSP to applet. Use ObjectOutputStream from the response object and send the vector. The applet should use the ObjectInputStream from the response object and retrieve the vector. Very simple.

Originally posted by Scott Williams:
Is it possible to pass a Vector from JSP to an applet? If so how? Thanks in advance.
Scott



------------------
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaRanch Common package has classes to send objects between an Applet/ Application and a Servlet.
 
Scott Williams
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies. I am encountering this exception (java.lang.IllegalStateException) now when the following line of code is being executed in my JSP.
ObjectOutputStream outputToApplet = new ObjectOutputStream(response.getOutputStream());
Any ideas???
Thank you.
 
Scott Williams
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the problem here is that the default output stream for JSP is of type JSPWriter and I am trying to change it to ObjectOutputStream. What do you guys think? Any experience with this??
Scott
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can only call getOutputStream once and the JSP engine has already done that to create the JSPWriter object out. You may find that you'll have to use a Servlet to do Object communication.
reply
    Bookmark Topic Watch Topic
  • New Topic