Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Bean and Servlet

Mohammed Zabin

2007-07-23

Replies:

Thank you Johnny,
To be specific this is my question
Hi all

I am trying to pass an object from a tag to a servlet. i did the following,

1. In the tag class, i put:

pageContext.getRequest().setAttribute("QList", list);



The above Tag will go to a servlet, i need to read the above request
attribute in the servlet, how can i do this?, i tried

List<Integer> list = (List<Integer>)request.getAttribute("QList");

, but when i tried to access the read list, it gave me
NullPointerException...What do u think?


On 7/23/07, Johnny Kewl <john@(protected):
>
> Hi Mohammed,
> Cant say I really understand the question....
>
> In general this is what the Session Objects are for....
> So say you have a servlet and a JSP page.... and say the servlet makes the
> bean with the Array List in it.... then if you
>
> session.setAttribute("MyBean", MyBean);
>
> you can get it (MyBean) back when the next call comes into say the JSP
> page....
>
> Now if you read up on this you will see you can also set 'request'
> objects.... and these are good for when you say dispatch a request to a
> JSP
> page from the servlet and want to pass a bean across.
>
> Anyway... if you just google for "servlet session and setAttribute"....
> you
> will be on your way... I think ;)
> This area of servlet programming is one of the things that make it such a
> powerful technology.
> Have fun...
>
> ----- Original Message -----
> From: "Mohammed Zabin" <jotnarta@(protected)>
> To: "Tomcat Users List" <users@(protected)>
> Sent: Monday, July 23, 2007 11:18 AM
> Subject: Bean and Servlet
>
>
> > Hi All
> > What is the best way to pass a list collection from a Bean to a Servlet?
> > Thank you
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
>
>
©2008 junlu.com - Jax Systems, LLC, U.S.A.