I want to transfer a String in request object from jsp to the servlet. In the jsp I use the following action
<BODY> <% pageContext.setAttribute("screen","adminscreen",PageContext.REQUEST_SCOPE); %> <A href="/admin/AdminServlet">Add new user Account</A><BR> <A href="/admin/AdminServlet">View esisting user Account</A> </BODY>
In the servlet code I'm simply trying to retreive it as shown below.
This will place the "screen" attribute in request scope for the life time of current request to your JSP page and it will be destroyed when you page is rendered.
Either store the attribute in Session Scope or pass it as a request parameter in the url like
and then retrieve it in your servlet using request.getParameter("screen")
Post by:Shyam kumar
, Ranch Hand
Thanks for the reply Ali, but I'm unable to undustand your it; You said that it will place the attribute in request scope for the current request... and then you said that the attribute will be destroyed!!! I mean the whole point of passing the http request object to the server is that we can store the attribute in the request scope and pass it to the server where we can later retreived and the attribute can be extracted!!! Can you please elaborate a little bit more... or you can tell me the page in HF servlet and jsp book where it is a little bit explained more.
Post by:arun shanmugam kumar
When the attribute is request scoped then it will live only for that particular request, unless the request is dispached to another servlet in the container. Here the JSP just returns the page to the client and at that point the request is completed and so do the scope the request attribute ends then and there.
Refer servlet 2.4 spec under the topic The Request and SRV4.10 subsection. [ March 25, 2007: Message edited by: arun s.k ]