Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

more SCWCD object question

 
Joe Man
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
12.7 Identify the method in the custom tag handler that accesses:
* A given JSP page's implicit variable
* The JSP page's attributes
Question:
1. All the (doStartTag(), doAfterBody(), doEndTag()) can access the JSP page's implict variable right? I guess i don't understand what they mean by which implicit variable.
2. Only the get and set method of the Attribute methods inside tag handler can access the JSP page's attributes? or they mean something else when they say page attributes?

Any feedback would be great! thanks!
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) No, not directly, it must use the PageContext Object to get access to the implicate Objects on a JSP Page
2) No, Tags have to use the PageContext to locate attributes from any scope.
All tags are created with a PageContext Object, this object provides access to the objects that exist on a JSP Page. So, to get at say the Session Object from a JSP Page you need:
HttpSession session = pageContext.getSession();
There are methods in PageContext for getRequest, getOut, getResponse, getPage etc.
To locate an attribute, PageContext has the methods
findAttribute(String name) which will find it in any of the scopes searching in order: page, request, session and application
getAttribute(String name) which only looks at the page scope
getAttribute(String name, int scope) which will find it in the scope specified. PageContext has a set of static variables to ease the definition of the scopes :
APPLICATION_SCOPE, PAGE_SCOPE, REQUEST_SCOPE etc.
[ May 20, 2002: Message edited by: Carl Trusiak ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic