If you are really there why don't you ask pageContext it has answer for all your implicit objects of JSP.
Thanks & Regards,<br />T.Srinivasan,<br />SCWCD 1.4(89%),SCJP 5.0(75%)<br />"That service is the noblest which is rendered for its own sake." - Mahatma Gandhi
Tiffiny Yang
Ranch Hand
Joined: Mar 29, 2006
Posts: 124
posted
0
how? Can you provide the code?
JspContext is the only implicit object used by simple tag handler, PageContext is not.
PageContext is one of the implicit objects used by classic tag handler.
JspContext does not provide access to ServletContext because Simple tag support is not bound to servlets. If you want to write a tag that needs some dependency on servlets I suggest to use classic tags.
There may be a question on this concept in the exam
I just wanted to add something tho what has been said so far.
Here's what the spec says in section JSP.7.1.5 about simple tags:
In addition to being simpler to work with, Simple Tag Extensions do not directly rely on any servlet APIs, which allows for potential future integration with other technologies. This is facilitated by the JspContext class, which PageContext now extends. JspContext provides generic services such as storing the JspWriter and keeping track of scoped attributes, whereas PageContext has functionality specific to serving JSPs in the context of servlets. Whereas the Tag interface relies on PageContext, SimpleTag only relies on JspContext.
However, when taking a look into SimpleTagSupport's API pages, this is what they say about the setJspContext method:
public void setJspContext(JspContext pc) Stores the provided JSP context in the private jspContext field. Subclasses can access the JspContext via getJspContext(). Parameters: pc - the page context for this invocation
I tried to output the result of getJspContext() instanceof PageContext inside a class extending SimpleTagSupport, and the result was that the Object returned was in fact a PageContext instance.
Being safe is different from being appropriate (good coding practice). If you happen to be using some non-servlet dependent framework/API in future your code may require lot of changes.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: How to get ServletConfig or ServeltContext object in the Simple Tag handler?