It depends on where you place your code:
1)
if you place it on the Jsp page itself
(using <% … %> ), you have access to
Jsp’s pageContext variable and you can
use pageContext.getSession()
2)
if you place it in your own Jsp tag (which
is not derived from X-Application’s
JspTag class), you will implement the
setPageContext method (or derive it from
SupportBodyTag)
3)
if you place it in your own Jsp tag (which
is derived from X-Application’s JspTag),
you have to overwrite JspTag.setPageContext()
in your tag. Basically, your method
“YourTag.setPageContext()” should store
the pageContext in a field of your class and
call the overridden method:
yourPageContextField = pageContext;
super.setPageContext(pageContext);
Now, you can use “yourPagecontextField”
to access the pageContext.
IMPORTANT: this solution is kind of a hack!
JspTag has a private pageContext field on
purpose:
we want to run Unit tests on tags derived
from JspTag - but the pageContext is not
available in unit tests (since instances of
PageContext are created by Tomcat)
By isolating all access to the pageContext
in the JspTag class, we can fake the
information taken from pageContext and
run unit-test our tage without running Tomcat.
Overwriting setPageContext would violate
this policy …
Michael
Software AG Germany, Darmstadt
X-Application Version: 3.1.2, 3.1.1
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 3.3
JDK Version : 1.3.1
X-Application Version: 3.1.2, 3.1.1
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 3.3
JDK Version : 1.3.1
#webMethods#API-Management#Tamino