Thank you I solve it using session, particularly:
pageContext.getSession().setAttribute("InQry", qry);

and retreive it in the servlet like this:
String inQry = (String)request.getSession().getAttribute("InQry");

But, I have a question regarding DBCP, it is not wrong to have more than one
CP, isn't it? I mean is it allowed to have a Resource for Oracle and another
for MySql?


On 7/24/07, David Smith <[EMAIL PROTECTED]> wrote:

Can you post the relevant parts of how/where you call this servlet?
I've never had a problem retrieving a request attribute after it was
added and before the end of the request.

--David

Mohammed Zabin wrote:
> Actually, I wanted to pass this list from within a Tag to be used inside
> another Servlet class, (i.e. the tag class after finishing rendering its
> elements, goes to a servlet, so, i need to pass this list to that
> servlet.
> As i have stated above, i used the following to store the list in the
> request object:
>
> [code]pageContext.getRequest().setAttribute("QList", list);[/code]
>
> In the servlet, i used the following to retrive the list:
>
> List<Integer> list = (List<Integer>)request.getAttribute(
> "QList");
>
> I tried to access the above list by a small code snippet that prints its
> size:
> [code]out.println( list.size() );[/code]
> But i got an exception stating that a NullPointerException has occured
at
> the size printing statement. That's mean, i think, the list didn't
stored
> correctly in the request object, am I true?
>
>
> On 7/23/07, David Smith <[EMAIL PROTECTED]> wrote:
>>
>> Typical design is servlet forwarding to jsp for view.  Tags being jsp
>> elements occur after servlets have executed.  So you can see how your
>> problem is a little curious in that jsps don't typically forward to
>> servlets.  If you are forwarding a request from jsp to servlet, let us
>> know.
>>
>> However if you are storing a object in a request during jsp execution
>> intending it to be available to the servlet on the next request, that
>> doesn't work.  The request is cleared and recycled when jsps finish
>> writing to the client.  When a new request comes in, the request
>> attribute list is empty.  If you need this list to live between
>> requests, you need to place it in the session.
>>
>> --David
>>
>> Mohammed Zabin wrote:
>>
>> > 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 <[EMAIL PROTECTED]> wrote:
>> >
>> >>
>> >> 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" <[EMAIL PROTECTED]>
>> >> To: "Tomcat Users List" <users@tomcat.apache.org>
>> >> 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@tomcat.apache.org
>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to