The Artima Developer Community
Sponsored Link

Java Answers Forum
Refirect and Forward

4 replies on 1 page. Most recent reply: Jun 18, 2003 1:31 AM by Manish

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Sarath Kumar

Posts: 4
Nickname: sarath
Registered: May, 2003

Refirect and Forward Posted: Jun 6, 2003 4:23 AM
Reply to this message Reply
Advertisement
Hi
Whatis the basic different of Refirect and Forward methods, nd which one is the fast, and also what is exact meaning of "peer" classes


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Refirect and Forward Posted: Jun 7, 2003 9:18 AM
Reply to this message Reply
Check out this link on Peer classes:
http://developer.java.sun.com/developer/qow/archive/75/index.html

At: http://java.sun.com/docs/books/tutorial/information/glossary.html

peer: In networking, any functional unit in the same layer as another entity.

I do not understand what you mean about Redirect and Forward methods. Which java class are you referring to?

Sarath Kumar

Posts: 4
Nickname: sarath
Registered: May, 2003

Redirect and Forward Posted: Jun 10, 2003 2:07 AM
Reply to this message Reply
Thanks for your reply.. I faced this question from one of the Ogranization Like " Which one is fast is it Redirect or is it Forward methode. This methods are aviable on Servlet Class
Thanks for your valuble reply

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Redirect and Forward Posted: Jun 14, 2003 1:35 PM
Reply to this message Reply
I think you are referring to the forward method of the class javax.servlet.jsp.PageContext

When using java server pages this is an easy way to redirect or forward the action to jsp pages or servlets as in the following jsp snippet:

if (desiredAction == null){
     pageContext.forward("getUserAction.jsp");				
}else if (desiredAction.compareTo("Read News") == 0){
     pageContext.forward("readNews.jsp");
}


I think they call this the "business logic" or the logic which controls how a web application functions.

Suggest you check out your servlet api documentation.

If you are using Tomcat its included in servletapi folder under Tomact docs. Use your web browser to navigate to the index.html page.

Manish

Posts: 2
Nickname: manish22nd
Registered: Jun, 2003

Re: Refirect and Forward Posted: Jun 18, 2003 1:31 AM
Reply to this message Reply
> Hi
> Whatis the basic different of Refirect and Forward
> methods, nd which one is the fast, and also what is exact
> meaning of "peer" classes

The forward method works inside the Web container. When you forward, the target page is invoked by the JSP container through an internal method call; the new page continues to process the same request and the browser is not aware of the fact that more than one page is involved. The sendRedirect method requires a round trip to the client. So the forward method is faster than sendRedirect. However, using the forward method restricts you to redirect only to a resource in the same Web application. The sendRedirect method, on the other hand, allows you to redirect to any URL. Another difference is that request scope objects are no longer available after a redirect because it results in a new request. If you need to pass data to the page you redirect to, you have to use a query string and pass them as request parameters (or save the data as session or application scope objects).
Conclusion: Use the forward method if it can solve your problem. Resort to the sendRedirect method only if you can't use the forward method. Forwarding is always faster, so that's the first choice.

Flat View: This topic has 4 replies on 1 page
Topic: JTable - Need Help Previous Topic   Next Topic Topic: JFrame

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use