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?

0


source to share


4 answers


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



+1


source


Have you tried request and not pageContext? Or just from the servlet itself:



getInitParameter("myInitParam");

      

0


source


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?

0


source


application.getInitParameter("<Name>");

      

0


source







All Articles