Danny Trieu wrote:

> Craig,
>

Well, I hope others could answer this one as well :-)

>
> what is the different between <jsp:forward .... /> and sendRedirect() ?
>

<jsp:forward> -- and it's cousin in the servlet API, RequestDispatcher.forward() --
happen on the server side.  What happens is your browser sends a request to a 
particular
URL, which invokes a servlet (or a JSP page).  That servlet (or JSP page) decides that 
a
different page should display the results for this very same request, so it does what
amounts to a "go to" to that page to display the results.  One extra benefit -- you can
pass request attributes to the new page using ServletRequest.setAttribute().

On the other hand, sendRedirect() sends an HTTP "moved temporarily" message back to 
your
browser, along with the new URL.  The browser then resubmits its request to the new
URL.  Depending on your connection speed to the network, this can take substantially
longer.

>
> Thansk
>

Craig


>
> "Craig R. McClanahan" wrote:
>
> > "Bailey, Jeff A" wrote:
> >
> > > Assuming i have this in a file called test.jsp
> > >
> > > <jsp:forward page="somepage.jsp" />
> > >
> > > Is there an easy way to update the url so that it shows the true location of
> > > the file http://blah.net/somepage.jsp instead of http://blah.net/test.jsp ?
> > >
> >
> > Forwarding happens on the server side, so the client browser is oblivious to it.
> > All it knows is that a response was returned for this request.  If you really want
> > to change the displayed location, use a sendRedirect() call instead, and pay the
> > performance price.
> >
> > >
> > > URL rewriting was a possible option but I cant figure out how to make it
> > > work if i want to move to a different directory level.  (ie <jsp:forward
> > > page="/root/somepage.jsp" /> where the current page is located at
> > > /root/somedir/someotherdir/test.jsp)
> > >
> >
> > None of this is going to help you change what the location bar in the browser
> > shows, for the reason described above.  As used in the servlet specification, "URL
> > rewriting" is a technique to maintain sessions when cookies are disabled -- it has
> > nothing to do with forwarding.
> >
> > I normally do my web applications in a framed environment, or in a customized
> > window with no location bar, to avoid having to worry about this issue.  My goal is
> > to provide enough GUI controls in the user interface for any navigation the user
> > wants (just like you have to do in a classical GUI app), without any reason to care
> > about the displayed location, or about the Previous and Next buttons.
> >
> > >
> > > Help :)
> > >
> > > Thanks in advance
> > >
> > > Jeff
> > >
> >
> > Craig McClanahan
> >
> > ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> > FAQs on JSP can be found at:
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to