Re: jsps not serving from context root in netbeans server




Lew wrote:
Dundonald wrote:
Yes I've been doing some googling and RTFMing as you advised ;) (well
I was doing that anyway) but I must admit despite reading the API and
a couple sites found on google so far it's still not clear how use of
this method can help with maintaining context root. I may well be
missing something.

My main points have to do with keeping the request and avoiding the round trip
to the client.

HttpServletResponse.sendRedirect() tells us that, "[i]f the location is
relative without a leading '/' the container interprets it as relative to the
current request URI. If the location is relative with a leading '/' the
container interprets it as relative to the servlet container root."

The leading '/' moves the redirect out of the context. I'm thinking that the
"current request URI" includes not only the application context root but the
specific resource handling the request. You might need to prefix the redirect
URL with "../".

However, I will say that most of what people want to do with a redirect is
better handled by the forward mechanism.

OK I've been doing some more reading of the APIs. I now understand
completely. The forward vs a redirect aside (as in the fact that the
redirect sends a response back to the browser to then send another
request for a specific resource), I now also understand about the
context root.

I have done some digging and a response.sendRedirect is still possible
IF the request.getContextPath() method is used to suppliment the jsp
name so for example:

resp.sendRedirect( resp.encodeURL( req.getContextPath() +
getJspNameToSendInResponse() ) )

or and as you have suggested I have also got it working with:

getServletContext().getRequestDispatcher(getJspNameToSendInResponse()).forward(getCurrentHttpServletRequest(),
resp);

where the current context of the current servlet is used to obtain the
dispatcher and then forward on.

Thanks!

So the only question I have now is, I'm assuming of course that the
encodeURL as used in the sendRedirect example is negligible in the
request dispatcher forward case?

.



Relevant Pages

  • Re: jsps not serving from context root in netbeans server
    ... resultant request for a jsp seems to be requested outside of the ... context root instead of using the context root and a 404 is returned. ... by redirect I mean a response.redirect. ...
    (comp.lang.java.programmer)
  • Re: Preventing Request.Form abuse
    ... I think I would redirect them to a large video file on one of the online ... also block their IP real time in the filter, so any future request from them ... If we were to use a real rather than a fictitious URL for the redirect, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HELP! - I need to setup a temporary IIS redirect while I fix SQL Injection vulnerabilities o
    ... Can I go a global redirect like this in IIS to prevent the request ... but it will NOT scan the Querystring. ... All it takes is a few encodings/permutations and ...
    (microsoft.public.inetserver.iis.security)
  • Re: NetApp filers 3rd party API
    ... then I'd trigger operations based on this request ... and finally redirect the request back to the NetApp. ...
    (comp.arch.storage)
  • Re: Regulation of the websites access
    ... The redirect feature functions exactly the same. ... When you specify the destination to which to redirect the request, ... ISA Server sends the URL specified here to the Web ... The client Web browser then tries to access the object from ...
    (microsoft.public.isa)