Status: New
Owner: ----

New issue 413 by jelleherold: invalid getRequestURL() after  
getRequestDispatcher().forward( ... )
http://code.google.com/p/google-guice/issues/detail?id=413

I have a filter like so:

public class F implements Filter {
  // ...
  public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException
  {
    request.getRequestDispatcher("/foo/bar.txt").forward(request, response);
  }
}

Then this servlet:

public class S extends HttpServlet {
   public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
   {
      final PrintWriter out = response.getWriter();
      out.println("Hello from " + request.getRequestURL());
   }
}

If this is configured through web.xml like so:

  <filter>
    <filter-name>f</filter-name>
    <filter-class>guice.test.F</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>f</filter-name>
    <url-pattern>/bug</url-pattern>
  </filter-mapping>
        
  <servlet>
    <servlet-name>s</servlet-name>
    <servlet-class>guice.test.S</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>s</servlet-name>
    <url-pattern>*.txt</url-pattern>
  </servlet-mapping>


When I request http://localhost:8080/guice.test/bug, I get:

  Hello from http://localhost:8080/guice.test/foo/bar.txt

If I configure the same thing through guiceFilter, I get

  Hello from http://localhost:8080/guice.test/bug


That is incorrect, see
http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/http/HttpServletRequest.html#getRequestURL()

In particular:

If this request has been forwarded using
RequestDispatcher.forward(javax.servlet.ServletRequest,
javax.servlet.ServletResponse), the server path in the reconstructed URL
must reflect the path used to obtain the RequestDispatcher, and not the
server path specified by the client.


Can you fix this? Or tell me where to fix it... ?


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to