Yet Another JSP Issue

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Yet Another JSP Issue

Tony Thompson
Well, if the other issue I reported about mapped JSPs is not confusing
enough, this is even better.  I will begin by attempting to outline what
I am doing in my application.  I have a JSP that resides in a web
application that attempts to get XML fragments out of other web
applications so it can display a menu in a browser.  So, the web
applications that are called must have a servlet mapping for the URL
/BuildMenu.  This is generally mapped to a JSP so that the menu content
can be generated on the fly.

It looks roughly like this:

/MenuBuilder/menu.jsp
    <c:import context="/app1" url="/BuildMenu"/>
    <c:import context="/app2" url="/BuildMenu"/>
    <c:import context="/app3" url="/BuildMenu"/>

So, internally, the <c:import> tag uses the RequestDispatcher to call
into each of the other applications.  In each application, there is a
servlet definition and mapping like this:

  <servlet>
    <servlet-name>BuildMenu</servlet-name>
    <jsp-file>/menu.jsp</jsp-file>
  </servlet>
  <servlet-mapping>
    <servlet-name>BuildMenu</servlet-name>
    <url-pattern>/BuildMenu</url-pattern>
  </servlet-mapping>

When the JSP is mapped like this, it causes this case to happen in
ServletHolder.java:

            // Handle aliased path
            if (_forcedPath!=null)
               
request.setAttribute("javax.servlet.include.servlet_path",_forcedPath);

This causes javax.servlet.include.servlet_path to be set to /menu.jsp
instead of /BuildMenu.  The issue is, Jasper uses this attribute at the
start of its JspServlet.service() method and, when set incorrectly, it
causes exceptions:

java.lang.StringIndexOutOfBoundsException: String index out of range:
-1
        at java.lang.String.substring(String.java:1762)
        at java.lang.String.substring(String.java:1735)
        at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:193)

I didn't send the rest of the stack trace because the line numbers in
the Jetty code would be wrong because I have been messing with things
trying to figure this out.  If I change the servlet mapping to a
<servlet-class> instead of a <jsp-file>, it works fine.

I have no idea why this is happening and I am willing to provide more
information to anyone who is able to tackle this.  I am using Jetty
5.1.5rc2.

Tony


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support