Question

I need to show two URLs into a JSP, but I want to pass some init parameters to the JSP page for doing this.

So, this is my web.xml :

<web-app ... >
<servlet>
    <servlet-name>index1</servlet-name>
    <jsp-file>/index.jsp</jsp-file>
    <init-param>
        <param-name>p1</param-name>
        <param-value>http://www.google.com</param-value>
    </init-param>
    <init-param>
        <param-name>p2</param-name>
        <param-value>/pagina2.jsp</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>index1</servlet-name>
    <url-pattern>/index.jsp</url-pattern>
</servlet-mapping>

In the index.jsp, I wrote the following code:

<%
    // This is only a test code. Obviously, it doesn't show the URLs
      java.util.Enumeration e = getServletConfig().getInitParameterNames();
      while( e.hasMoreElements() ) {
          out.println( e.nextElement() + "<br>");
      }
    %>

But when I run the jsp, this show some initParameters that I don't need. By example: logVerbosityLevel
httpMethods
keepgenerated
p2 ----------- > This is the parameter that I need

xpoweredBy
p1 ----------- > This is other parameter that I need
system-jar-includes
com.sun.appserv.jsp.classpath

My questions is: Why the JSP file are using all this parameters?
Note: I'm using Glassfish.

Was it helpful?

Solution

Those are the initialization parameters of the container-builtin JspServlet class who's responsible for serving JSP files. In case of Glassfish, you can find it in config/default-web.xml file of the domain. It's the servlet entry of org.apache.jasper.servlet.JspServlet (note, you should not modify it unless you really understand what you're doing).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top