Reputation: 11
I'm trying to create a jsp tag file but it fails to compile when I try to use pageContext.getServletConfig().getInitParameter("myInitParam")
I'm using tomcat and when I try to view a page including the file I get a jasper compile error pageContext cannot be resolved. I've also tried just using getInitParameter
but it fails also. I can use the request object so I know everything else is fine.
Does anyone know a way to access init parameters set in the web.xml from a jsp tag file, preferably from within a scriptlet?
Upvotes: 0
Views: 1333
Reputation: 11
I just found out the trick is to use one of the implicit objects, in this case config or application depending on the init-parameters scope. they are list at http://today.java.net/pub/a/today/2003/11/14/tagfiles.html
Upvotes: 1
Reputation: 139921
Are you extending the TagSupport class?
If so, this class has a member named pageContext
, the Tag interface declares a method setPageContext(PageContext pc)
, which the docs state
This method is invoked by the JSP page implementation object prior to doStartTag().
So you should be able to reference this.pageContext
fine - unless you are extending a different class?
Upvotes: 0
Reputation: 61414
Have you tried the request rather than the pageContext? Or just off the servlet itself:
getInitParameter("myInitParam");
Upvotes: 0