codependent
codependent

Reputation: 24452

JSP fails with pagecontext cannot be resolved when accessing pageContext in a scriptlet contained in a taglib in JBoss

I have a JEE application that was deployed on Websphere and I'm migrating it to JBoss.

Some JSPs use a custom tablig where the pageContext is accessed to check and store variables.

Having a simple JSP like...

<%= pageContext %>

... it works fine.

However, when the same thing is inside my taglib if fails with pageContext cannot be resolved

Custom taglib:

<%@tag body-content="scriptless" description="xxx"%>
<%=pageContext %>

JSP:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"  isErrorPage="false"%>

<xxx:mytag/>

Oddly enough, if the taglib is :

<%@tag body-content="scriptless" description="xxx"%>
${pageContext}

... it works, showing org.apache.jasper.runtime.JspContextWrapper@xxx:

How can I make it work with usual scriptlets?

Upvotes: 0

Views: 821

Answers (1)

codependent
codependent

Reputation: 24452

For some reason, pageContext is not available inside a TagLib's scriptlet. However jspContext, which is PageContext's parent class is, so that workaround fixed it for me:

<%@tag body-content="scriptless" description="xxx"%>
<%=jspContext %>

Upvotes: 1

Related Questions