5 Replies Latest reply on Oct 1, 2002 11:02 AM by pichler.mi

    JSP sendRedirect broken from JSP welcome-file in subdir?

    pichler.mi

      Hello,

      I just tried jboss 3.0.2 with jetty 1.4.

      Our webapp defines a welcome-file in a subdirectory, e.g.
      subdir/Welcome.jsp which should redirect to a relative location. When
      running it in tomcat or jetty standalone it works (it also worked with
      jboss 3.0.0 with tomcat), but with the combination above, the redirect
      URI is interpreted relative to the server root (even outside the
      application context), not the location of the jsp file.

      The difference (bug?) can also be observed with request.getRequestURL().

      A simplified version of the webapp is attacht as welcome.war. Any
      clues what's wrong? PS: We have found jboss a great product besides
      this minor glitch.

      --- subdir/Welcome.jsp ---
      <% response.sendRedirect ("target.html"); %>
      Server Info: <%= application.getServerInfo()%>
      Request URI: <%= request.getRequestURI()%>
      Full URL: <%= request.getRequestURL ()%>

      --- Jetty alone ---
      GET /welcome/ HTTP/1.0
      HTTP/1.1 302 Moved Temporarily
      Server: Jetty/4.0.5 (Windows 2000 5.0 x86)
      Servlet-Engine: Jetty/1.1 (Servlet 2.3; JSP 1.2; java 1.4.0)
      Location: http://192.168.x.y:8080/welcome/subdir/target.html

      Server Info: Jetty/1.1

      Request URI: /welcome/subdir/Welcome.jsp
      Full URL: http://192.168.xxx.xxx:8080/welcome/subdir/Welcome.jsp

      --- jboss 3.0.2 with jetty ---
      GET /welcome/ HTTP/1.0
      HTTP/1.1 302 Moved Temporarily
      Server: Jetty/RELEASE_MAJOR_MINOR (Linux 2.4.18-64GB-SMP i386)
      Servlet-Engine: Jetty/RELEASE_MAJOR_MINOR (Servlet 2.3; JSP 1.2; java 1.4.0)
      Location: http://192.168.153.181:8080/target.html

      Server Info: Jetty/RELEASE_MAJOR_MINOR
      Request URI: /welcome/subdir/Welcome.jsp
      Full URL: http://192.168.x.y:8080/welcome/

        • 1. Re: JSP sendRedirect broken from JSP welcome-file in subdir?
          gregwilkins

          I'm pretty sure that such welcome files are not legal and
          your lucky that they work at all!

          I would suggest that you keep the welcome files in the
          current directory.

          You can always create an index in the parent directory
          that contains a meta redirect to the subdirectory.

          If I was to make a change for this, it would be to
          throw an exception is we saw such a welcome file. Sorry.

          I'm going to ask JSR154 if they can clarify this in the 2.4 spec.

          • 2. Re: JSP sendRedirect broken from JSP welcome-file in subdir?
            gregwilkins

            Correcting myself a little....

            a welcome file like you have /subdir/index.html
            is not legal, but subdir/index.html is.

            The spec says that a welcome file partial URI should
            not contain a leading or trailing "/"

            • 3. Re: JSP sendRedirect broken from JSP welcome-file in subdir?
              pichler.mi

              It didn't work with subdir/Welcome.jsp either, but, OK, a welcome-file that redirects into another directory is probably a bad idea anyways.

              Thus I have changed the welcome-file to plain Hello.jsp located in the root dir of the webapp (hello.war) which does
              <% response.sendRedirect ("subdir/target.html"); %>

              That seems legal to me and works for Jetty alone, but not with JBoss 3.0.2 when just requesting "/hello/" (or "/hello" whicht gets redirected to "/hello/"); Also notice the different value of request.getRequestURL() which is taken as base for the redirect.

              BTW, the redirect works as expected when accessing "/hello/Hello.jsp" explicitly. The problem is only with a JSP welcome file performing a redirect.

              --- Jetty alone ---
              GET /hello/ HTTP/1.0
              HTTP/1.1 302 Moved Temporarily
              Server: Jetty/4.1.0RC4 (Windows 2000 5.0 x86)
              Servlet-Engine: Jetty/4.1.0RC4 (Servlet 2.3; JSP 1.2; java 1.4.0)
              Location: http://192.168.x.y:8080/hello/subdir/target.html

              Server Info: Jetty/4.1.0RC4
              Request URI: /hello/Hello.jsp
              Full URL: http://192.168.x.y:8080/hello/Hello.jsp

              --- JBoss+Jetty ---
              GET /hello/ HTTP/1.0
              HTTP/1.1 302 Moved Temporarily
              Server: Jetty/RELEASE_MAJOR_MINOR (Linux 2.4.18-64GB-SMP i386)
              Servlet-Engine: Jetty/RELEASE_MAJOR_MINOR (Servlet 2.3; JSP 1.2; java 1.4.0)
              Location: http://192.168.x.y:8080/subdir/target.html

              Server Info: Jetty/RELEASE_MAJOR_MINOR
              Request URI: /hello/Hello.jsp
              Full URL: http://192.168.x.y:8080/hello/

              • 4. Re: JSP sendRedirect broken from JSP welcome-file in subdir?
                pichler.mi

                [Think I've hit the wrong reply button the first thime. Sorry if you see this twice.]

                It didn't work with subdir/Welcome.jsp either, but, OK, a welcome-file that redirects into another directory is probably a bad idea anyways.

                Thus I have changed the welcome-file to plain Hello.jsp located in the root dir of the webapp (hello.war) which does
                <% response.sendRedirect ("subdir/target.html"); %>

                That seems legal to me and works for Jetty alone, but not with JBoss 3.0.2 when just requesting "/hello/" (or "/hello" whicht gets redirected to "/hello/"); Also notice the different value of request.getRequestURL() which is taken as base for the redirect.

                BTW, the redirect works as expected when accessing "/hello/Hello.jsp" explicitly. The problem is only with a JSP welcome file performing a redirect.

                --- Jetty alone ---
                GET /hello/ HTTP/1.0
                HTTP/1.1 302 Moved Temporarily
                Server: Jetty/4.1.0RC4 (Windows 2000 5.0 x86)
                Servlet-Engine: Jetty/4.1.0RC4 (Servlet 2.3; JSP 1.2; java 1.4.0)
                Location: http://192.168.x.y:8080/hello/subdir/target.html

                Server Info: Jetty/4.1.0RC4
                Request URI: /hello/Hello.jsp
                Full URL: http://192.168.x.y:8080/hello/Hello.jsp

                --- JBoss+Jetty ---
                GET /hello/ HTTP/1.0
                HTTP/1.1 302 Moved Temporarily
                Server: Jetty/RELEASE_MAJOR_MINOR (Linux 2.4.18-64GB-SMP i386)
                Servlet-Engine: Jetty/RELEASE_MAJOR_MINOR (Servlet 2.3; JSP 1.2; java 1.4.0)
                Location: http://192.168.x.y:8080/subdir/target.html

                Server Info: Jetty/RELEASE_MAJOR_MINOR
                Request URI: /hello/Hello.jsp
                Full URL: http://192.168.x.y:8080/hello/

                • 5. Re: JSP sendRedirect broken from JSP welcome-file in subdir?
                  pichler.mi

                  It works well with jboss 3.0.3 (bug 611044 closed)
                  for both the hello example and our application with a
                  welcome-file in a subdirectory (without leading /).

                  Thanks.

                  --- JBoss 3.0.3 + Jetty 4.1.0 ---
                  GET /hello/ HTTP/1.0
                  HTTP/1.1 302 Moved Temporarily
                  Server: Jetty/4.1.0 (Windows 2000 5.0 x86)
                  Servlet-Engine: Jetty/4.1.0 (Servlet 2.3; JSP 1.2; java 1.4.1)
                  Location: http://192.168.x.y:8080/hello/subdir/target.html

                  Request URI: /hello/Hello.jsp
                  Full URL: http://192.168.x.y:8080/hello/Hello.jsp

                  --- JBoss 3.0.3 + Tomcat 4.1.12 ---
                  GET /hello/ HTTP/1.0
                  HTTP/1.1 302 Moved Temporarily
                  Server: Apache Tomcat/4.1.12-LE-jdk14 (HTTP/1.1 Connector)
                  Location: http://localhost:8080/hello/Hello.jsp

                  <h1>HTTP Status 302 - Moved Temporarily</h1>

                  GET /hello/Hello.jsp HTTP/1.0
                  HTTP/1.1 302 Moved Temporarily
                  Server: Apache Tomcat/4.1.12-LE-jdk14 (HTTP/1.1 Connector)
                  Location: http://localhost:8080/hello/subdir/target.html