Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JSP Interest »

Re: How-to pass a object class in a form jsp

Bryan LaPlante

2004-04-16


I don't know if this will help you but a word of warning, do not accept an
object submitted through a web interface unless you know what it is. That
said, to cache object state I have loaded a hidden field with serialized
data so that I could retrieve it. Below is the serialize but I left off the
Base64.encode and decode methods you will need to store it safely in a html
input filed.

public class SerializableObject {
 
 public static ByteArrayOutputStream serialize(Object obj) throws Exception{
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   ObjectOutputStream fout = new ObjectOutputStream( out );
   fout.writeObject(obj);
   return out;
 }
 
 public static Object deSerialize(InputStream in) throws Exception{
   ObjectInputStream fin = new java.io.ObjectInputStream(in);
   return fin.readObject();
 }
}

>On      Fri, 16 Apr 2004 13:48:31 -0600 "F. Sindran"
<falagueiro@(protected).
>Hello!

>

>In struts html:hidden tag only accepts form fields of javaLang type string.

>I need when I submit the form, the action will be able to receive a java

>object, for instance, a javalang list.

>Another option that can resolve the problem, would be add an attribute

>(list) to the request inside jsp page. Is it possible?

>

>Thanks in advance.

>

>--

>Un cordial saludo,

>F. SindrĂ¡n

>

>===========================================================================

>To unsubscribe: mailto listserv@(protected)

>JSP-INTEREST".

>For digest: mailto listserv@(protected)

>DIGEST".

>

>Some relevant archives, FAQs and Forums on JSPs can be found at:

>

> http://java.sun.com/products/jsp

> http://archives.java.sun.com/jsp-interest.html

> http://forums.java.sun.com

> http://www.jspinsider.com

>

>

===========================================================================
To unsubscribe: mailto listserv@(protected)".
For digest: mailto listserv@(protected)".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com
©2008 junlu.com - Jax Systems, LLC, U.S.A.