aspose file tools
The moose likes JSP and the fly likes accessing request implicit object in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "accessing request implicit object in JSP" Watch "accessing request implicit object in JSP" New topic
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
    
  11

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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: accessing request implicit object in JSP
 
Similar Threads
request attributes
Accessing userPrincipal via EL - why doesn't this work?
Writing Cookies
Accessing JSP implicit objects from outsite the JSP page itself
Quick question on session attributes