• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing object with request scope in a custom tag handler  RSS feed

 
Chanchal Jacob
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody please tell me how can i access an object set in the request using request.setAttribute() from inside my tag handler class

Chanchal
 
Amol Fuke
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chanchal,

You can use the pageContext field which will give you request object.
something like this:
Request req = pageContext.getRequest();

Thanks,
Amol
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you do not have another attribute with the same name in any other scope, you could use the findAttribute(String name) method of the pageContext object.


Object findAttribute(String name):::Searches for the named attribute in page, request, session (if valid), and application scope(s) in order and returns the value associated or null.


ram.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot to mention, that the pageContext variable of type javax.servlet.jsp.PageContext is available to all tag classes as an implicit object inherited from javax.servlet.jsp.tagext.TagSupport

ram.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!