my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes [OCWCD] How can I get pageContext in SimpleTagSupport Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "[OCWCD] How can I get pageContext in SimpleTagSupport Object" Watch "[OCWCD] How can I get pageContext in SimpleTagSupport Object" New topic
Author

[OCWCD] How can I get pageContext in SimpleTagSupport Object

Paulo Gervásio.
Greenhorn

Joined: Aug 14, 2010
Posts: 12
Hi Everyone,

I tried catch the Session through the SimpleTagSupport, and I could not...

But I read in the Heard First Book that the SimpleTagSupport is used in 99,99999% of the tags, (so... Should there are a method to do this, right!?)

I also beyond the Sessions, want to catch the ServletContext object

So... How can I do it?


Thanks.

Paulo Gervásio.


SCJP
Paulo Gervásio.
Greenhorn

Joined: Aug 14, 2010
Posts: 12
Hey!

I found the method:



But I cannot understand because getJspContext(); don't returns a PageContext object... Somebody knows?


Thanks.
Paulo Gervásio.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Hi Paulo,

But I cannot understand because getJspContext(); don't returns a PageContext object... Somebody knows?

True, but PageContext extends JspContext

The JspContext is described like this:
JspContext serves as the base class for the PageContext class and abstracts all
information that is not specific to servlets. This allows for Simple Tag Extensions
to be used outside of the context of a request/response Servlet.


As we are using SimpleTags always in an environment that is Servlet-based (in JSPs, those are Servlets) you can safely downcast the JspContext to the PageContext object.

Regards,
Frits
Paulo Gervásio.
Greenhorn

Joined: Aug 14, 2010
Posts: 12
Good!
Thnks!
 
 
subject: [OCWCD] How can I get pageContext in SimpleTagSupport Object
 
Similar Threads
Access HttpServletRequest from within SimpleTagSupport
Getting parameters from a SimpleTagSupport derived handler
SimpleTagSupport
Writing My Tag Handler by SimpleTagSupport
Getting Request Object Inside SimpleTag