0

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?

sblundy
  • 60,628
  • 22
  • 121
  • 123
user45023
  • 11
  • 2

4 Answers4

1

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

user45023
  • 11
  • 2
0
application.getInitParameter("<Name>");
0

Have you tried the request rather than the pageContext? Or just off the servlet itself:

getInitParameter("myInitParam");
sblundy
  • 60,628
  • 22
  • 121
  • 123
0

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?

matt b
  • 138,234
  • 66
  • 282
  • 345