| Author |
accessing request implicit object in JSP
|
Ken Sampson
Ranch Hand
Joined: Sep 26, 2007
Posts: 45
|
|
Hello, I understand that I need to access the request attribute object in a jsp using the following: <% request.getAttribute("username")%> assuming there exists an attribute as username. But here I am using scriplets which should be avoided. I would like to try the same thing using EL. Using the implicit pageContext object I may be able to do the following: ${pageContext.request.method} to get GET or POST as the method. But how can I access an attribute and perform the above operation. I tried to do this: ${pageContext.request.attribute} but this won't work. Is there any workaround for this or I need to do this always using Scriplets.
|
Ken Sampson
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
In EL there is also an implicit object called requestScope : ${requestScope.username}. If the username is only in the request scope, you can even get it via ${username}. In this case, the container will look in all scopes (page,request, session, and application scopes) for the attribute and return it when found.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Ken Sampson
Ranch Hand
Joined: Sep 26, 2007
Posts: 45
|
|
|
Thank you all so much!!!
|
 |
 |
|
|
subject: accessing request implicit object in JSP
|
|
|