You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Marc Boorshtein <mb...@gmail.com> on 2015/12/24 15:37:11 UTC

Very Strange 404 to JSP with getRequestDispatcher().forward()

All,

I'm having a very strange issue with
request.getServletContext().getRequestDispatcher().forward().  It gives me
a 404 on a JSP page that if I go to directly, works fine.  This is with
tomcat 8.0.30 on OSX on JDK :

ava version "1.7.0_65"

Java(TM) SE Runtime Environment (build 1.7.0_65-b17)

Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

What makes this a bit different is that the request object is wrapped with
a couple of implementations of HttpRequestWrapper.  The methods that seem
to matter (getAttribute and setAttribute) are just passthroughs.  After
doing some debugging, I've traced the main issue to the JspServlet where
the jspUri variable is being set to the original URI
(/auth/idp/MyIdP/completeFed) not the forwarded URI
(/auth/fed/postauthnresp.jsp).  The request being passed into the
JspServlet's service method is the same request object as is being sent to
the forward method.

This code works perfectly well under Jetty as a frame of reference.  Any
help would be greatly appreciated.

Thanks

Marc

Re: Very Strange 404 to JSP with getRequestDispatcher().forward()

Posted by Marc Boorshtein <mb...@gmail.com>.
>
>
>
> Your request wrappers store their own reference to a
> HttpServletRequest in addition to the one stored by the
> ServletRequestWrapper class.
>
>
> My guess is that your issue will be solved if you either override
> ServletRequestWrapper.setRequest() to update your request field,  or
> use ServletRequestWrapper.getRequest() method to access the wrapped
> object, instead of storing it by yourself.
>
>
Sounds like good advise.

Thanks

Re: Very Strange 404 to JSP with getRequestDispatcher().forward()

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-12-24 18:12 GMT+03:00 Marc Boorshtein <mb...@gmail.com>:
>>
>> You have to provide the actual source code.
>>
>> There is an example in the examples webapp that performs forwarding to
>> a JSP and it works,
>>
>> \webapps\examples\WEB-INF\classes\ServletToJsp.java
>>
>>
> So the good news is that I got it to work by getting rid of any of the
> methods that were overiding the implementation with a call to the child
> request.  Here's the links to the code that does NOT work : (I haven't
> checked in the working code yet):
>
> https://github.com/TremoloSecurity/OpenUnison/blob/1.0.6-Dev/unison/unison-server-core/src/main/java/com/tremolosecurity/proxy/ProxyRequest.java
>
> https://github.com/TremoloSecurity/OpenUnison/blob/1.0.6-Dev/unison/unison-server-core/src/main/java/com/tremolosecurity/embedd/LocalSessionRequest.java

Your request wrappers store their own reference to a
HttpServletRequest in addition to the one stored by the
ServletRequestWrapper class.


My guess is that your issue will be solved if you either override
ServletRequestWrapper.setRequest() to update your request field,  or
use ServletRequestWrapper.getRequest() method to access the wrapped
object, instead of storing it by yourself.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Very Strange 404 to JSP with getRequestDispatcher().forward()

Posted by Marc Boorshtein <mb...@gmail.com>.
>
> You have to provide the actual source code.
>
> There is an example in the examples webapp that performs forwarding to
> a JSP and it works,
>
> \webapps\examples\WEB-INF\classes\ServletToJsp.java
>
>
So the good news is that I got it to work by getting rid of any of the
methods that were overiding the implementation with a call to the child
request.  Here's the links to the code that does NOT work : (I haven't
checked in the working code yet):

https://github.com/TremoloSecurity/OpenUnison/blob/1.0.6-Dev/unison/unison-server-core/src/main/java/com/tremolosecurity/proxy/ProxyRequest.java

https://github.com/TremoloSecurity/OpenUnison/blob/1.0.6-Dev/unison/unison-server-core/src/main/java/com/tremolosecurity/embedd/LocalSessionRequest.java

 Thanks
Marc

Re: Very Strange 404 to JSP with getRequestDispatcher().forward()

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-12-24 17:37 GMT+03:00 Marc Boorshtein <mb...@gmail.com>:
> All,
>
> I'm having a very strange issue with
> request.getServletContext().getRequestDispatcher().forward().  It gives me
> a 404 on a JSP page that if I go to directly, works fine.  This is with
> tomcat 8.0.30 on OSX on JDK :
>
> ava version "1.7.0_65"
>
> Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
>
> Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
>
> What makes this a bit different is that the request object is wrapped with
> a couple of implementations of HttpRequestWrapper.  The methods that seem
> to matter (getAttribute and setAttribute) are just passthroughs.  After
> doing some debugging, I've traced the main issue to the JspServlet where
> the jspUri variable is being set to the original URI
> (/auth/idp/MyIdP/completeFed) not the forwarded URI
> (/auth/fed/postauthnresp.jsp).  The request being passed into the
> JspServlet's service method is the same request object as is being sent to
> the forward method.
>
> This code works perfectly well under Jetty as a frame of reference.  Any
> help would be greatly appreciated.


You have to provide the actual source code.

There is an example in the examples webapp that performs forwarding to
a JSP and it works,

\webapps\examples\WEB-INF\classes\ServletToJsp.java


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org