DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3727>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3727

Switched included request parameters

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |



------- Additional Comments From [EMAIL PROTECTED]  2001-09-20 15:14 -------
My fault! What the forward() call concerns you're right. It does not modify any
attributes. I actually meant an include() call (a bad copy paste error in my
previous description, sorry). I rechecked the behavior with a very simple
servlet that recursively includes itself exactely once. The code looks like:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public final class SnoopIncluderServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, java.io.IOException {

        if(req.getAttribute("hop") == null) {
            req.setAttribute("hop", "true");

            RequestDispatcher disp = null;
            disp = getServletContext().getRequestDispatcher("/servlet/" +
getClass().getName());
            resp.setContentType("text/plain");
            disp.include(req, resp);
        }
        else {
            PrintWriter out = resp.getWriter();
            out.println("request attributes");
            java.util.Enumeration attrs = req.getAttributeNames();
            while (attrs.hasMoreElements()) {
                String attr = (String) attrs.nextElement();
                out.println(attr + " = " + req.getAttribute(attr));
            }
        }
    }
}

The corrsponding web.xml file is:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd";>

<web-app>
    <servlet>
      <servlet-name>
         SnoopIncluder
      </servlet-name>
      <servlet-class>
         SnoopIncluderServlet
      </servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>
           SnoopIncluder
        </servlet-name>
        <url-pattern>
            /
        </url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>
           SnoopIncluder
        </servlet-name>
        <url-pattern>
            /*
        </url-pattern>
    </servlet-mapping>
</web-app>

The result I get after setting up the context in Tomcat's config files:

javax.servlet.include.path_info = /servlet/SnoopIncluderServlet
javax.servlet.include.servlet_path =
javax.servlet.include.context_path = /appsvtest
javax.servlet.include.request_uri = /appsvtest/servlet/SnoopIncluderServlet
hop = true

As you can see the Tomcat in fact switches the values of the path info and the
servlet path.

Paradoxically this behavior dispears by adding another (dummy) url mapping to
the web.xml file, e.g.:

    <servlet-mapping>
        <servlet-name>
           SnoopIncluder
        </servlet-name>
        <url-pattern>
            /foobar/*
        </url-pattern>
    </servlet-mapping>

We now get the following output from Tomcat:

javax.servlet.include.servlet_path = /servlet/SnoopIncluderServlet
javax.servlet.include.context_path = /appsvtest
javax.servlet.include.request_uri = /appsvtest/servlet/SnoopIncluderServlet
hop = true


As further tests have shown Tomcat 3.2.3 behaves very similar.

Reply via email to