Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

passing a Vector from JSP to an applet

 
Scott Williams
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to pass a Vector from JSP to an applet? If so how? Thanks in advance.
Scott
 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • 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.
 
Mohamed Yousuff
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • 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


------------------
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!