• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

forward

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have some doubts in servlets.

1) forward method dispatches the resuest to another resource. it only dispatches the request or it dispatches the response also?

2) there is one abc.jsp page . and when we invoke sendredirect method it moved to xyz.jsp page.

is request in abc.jsp page available in xyz.page?

thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first question can by answered by the API:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html#forward(javax.servlet.ServletRequest,%20javax.servlet.ServletResponse)
(Look at the argument list in the signature of the forward method)

The answer to the second question is no.
Unlike a forward, the sendRedirect method works by sending a response to the browser asking it to make a brand new request for the other page.
If you install a packet sniffer or a tool like the LiveHttpHeaders plugin for FireFox, you can see all of this happen in the request and response headers.
[ July 01, 2007: Message edited by: Ben Souther ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pravanya kantipudi:
i have some doubts in servlets.

1) forward method dispatches the resuest to another resource. it only dispatches the request or it dispatches the response also?

2) there is one abc.jsp page . and when we invoke sendredirect method it moved to xyz.jsp page.

is request in abc.jsp page available in xyz.page?

thanks



1.Same request and response objects created for the first resource will be dispatched to the second resource when making use of forward().

2.sendRedirect() makes use of new request and response objects in another resource.
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:


If you install a packet sniffer or a tool like the LiveHttpHeaders plugin for FireFox, you can see all of this happen in the request and response headers.



Thanks!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Sudhakar K ",
Welcome to JavaRanch!

We're pleased to have you here with us here on the ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. You can change it here
[ July 03, 2007: Message edited by: Ben Souther ]
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually both servlets use the same request and response objects,

the output generated by the first servlet will be discarded,u can only get the output of second servlet

in case of sendredirect the browser will be sending the new request,it'll create new request and response objects

hope it is clear now
 
Die Fledermaus does not fear such a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic