How to access init parameters from JSP2 tag file?
I'm trying to create a jsp tag file but it won't compile when I try to use pageContext.getServletConfig().getInitParameter("myInitParam")
I am using tomcat and when I try to view the page including the file I get jasper compilation error. The context could not be resolved. I also tried using getInitParameter
but it doesn't work either. I can use the request object so that I know everything else is fine.
Does anyone know a way to access init parameters set in web.xml file from jsp tag file, preferably from within a script?
source to share
I just figured out that the trick is to use one of the implicit objects, in this case config or application depending on the init-parameters scope. they are listed at http://today.java.net/pub/a/today/2003/11/14/tagfiles.html
source to share
Are you extending the TagSupport class ?
If so, this class has a member named pageContext
, the tag interface declares a method setPageContext(PageContext pc)
that tells the docs
This method is called by the JSP page implementation object before doStartTag ().
So, you should be able to reference this.pageContext
fine - unless you are extending another class?
source to share