jfarcand    2003/09/09 18:47:24

  Modified:    jasper2/src/share/org/apache/jasper/servlet JspServlet.java
  Log:
  Fix jsp-config problem reported by Kin-Man:
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <web-app xmlns="http://java.sun.com/xml/ns/j2ee";
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
      version="2.4">
    <jsp-config>
    <jsp-property-group>
      <url-pattern>/utf16/*</url-pattern>
      <page-encoding>UTF-16</page-encoding>
    </jsp-property-group>
    </jsp-config>
  </web-app>
  
  Create a file in /utf16/foo.jsp:
  Create a file in /test.jsp
      Begin
      <jsp:include page="utf16/foo.jsp" />
      End
  
  The include was falling. I'm implementing the fix here since I don't think 
implementing jsp-config on the servlet side is correct.
  
  Revision  Changes    Path
  1.31      +49 -33    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServlet.java
  
  Index: JspServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServlet.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- JspServlet.java   2 Sep 2003 21:39:59 -0000       1.30
  +++ JspServlet.java   10 Sep 2003 01:47:24 -0000      1.31
  @@ -186,18 +186,34 @@
                         HttpServletResponse response)
        throws ServletException, IOException {
   
  -     try {
  +        try {
               String includeUri 
                   = (String) request.getAttribute(Constants.INC_SERVLET_PATH);
  -
  +            String requestUri 
  +                = (String) request.getAttribute(Constants.INC_REQUEST_URI);
  +            
               String jspUri;
  +            
  +            // When jsp-property-group/url-matching is used, and when the 
  +            // jsp is not defined with <servlet-name>, the url
  +            // as to be passed as it is to the JSP container (since 
  +            // Catalina doesn't know anything about the requested JSP 
  +            
  +            // The first scenario occurs when the jsp is not directly under /
  +            // example: /utf16/foo.jsp
  +            if (requestUri != null){
  +                String currentIncludedUri 
  +                    = requestUri.substring(requestUri.indexOf(includeUri));
   
  +                if ( !includeUri.equals(currentIncludedUri) ) {
  +                    includeUri = currentIncludedUri;
  +                }
  +            }
  +
  +            // The second scenario is when the includeUri is null but it 
  +            // is still possible to recreate the request.
               if (includeUri == null) {
  -             jspUri = request.getServletPath();
  -                // When jsp-property-group/url-matching is used, and when the 
  -                // jsp is not defined with <servlet-name>, the url
  -                // as to be passed as it is to the JSP container (since 
  -                // Catalina doesn't know anything about the requested JSP 
  +                jspUri = request.getServletPath();
                   if (request.getPathInfo() != null) {
                       jspUri = request.getServletPath() + request.getPathInfo();
                   }
  @@ -212,40 +228,40 @@
   
               boolean precompile = preCompile(request);
   
  -         if (log.isDebugEnabled()) {     
  -             log.debug("JspEngine --> " + jspUri);
  -             log.debug("\t     ServletPath: " + request.getServletPath());
  -             log.debug("\t        PathInfo: " + request.getPathInfo());
  -             log.debug("\t        RealPath: " + context.getRealPath(jspUri));
  -             log.debug("\t      RequestURI: " + request.getRequestURI());
  -             log.debug("\t     QueryString: " + request.getQueryString());
  -             log.debug("\t  Request Params: ");
  -             Enumeration e = request.getParameterNames();
  +            if (log.isDebugEnabled()) {          
  +                log.debug("JspEngine --> " + jspUri);
  +                log.debug("\t     ServletPath: " + request.getServletPath());
  +                log.debug("\t        PathInfo: " + request.getPathInfo());
  +                log.debug("\t        RealPath: " + context.getRealPath(jspUri));
  +                log.debug("\t      RequestURI: " + request.getRequestURI());
  +                log.debug("\t     QueryString: " + request.getQueryString());
  +                log.debug("\t  Request Params: ");
  +                Enumeration e = request.getParameterNames();
   
  -               while (e.hasMoreElements()) {
  +                while (e.hasMoreElements()) {
                       String name = (String) e.nextElement();
                       log.info("\t\t " + name + " = " +
                                request.getParameter(name));
                   }
  -         }
  +            }
   
               serviceJspFile(request, response, jspUri, null, precompile);
  -     } catch (RuntimeException e) {
  -         throw e;
  -     } catch (ServletException e) {
  -         throw e;
  -     } catch (IOException e) {
  -         throw e;
  -     } catch (Throwable e) {
  -         throw new ServletException(e);
  -     }
  +        } catch (RuntimeException e) {
  +            throw e;
  +        } catch (ServletException e) {
  +            throw e;
  +        } catch (IOException e) {
  +            throw e;
  +        } catch (Throwable e) {
  +            throw new ServletException(e);
  +        }
   
       }
   
       public void destroy() {
  -     if (log.isDebugEnabled()) {
  -         log.debug("JspServlet.destroy()");
  -     }
  +        if (log.isDebugEnabled()) {
  +            log.debug("JspServlet.destroy()");
  +        }
           rctxt.destroy();
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to