• 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 in JSP

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys....I have been Haunted by this question by number of Interviewers . It's Kind of a pet question of the panel .
1) WHAT ARE THE DIFFERENT WAYS TO FORWARD TO ANOTHER RESOURCE IN JSP .
My Ans :- Using JSP Forward Tag , Using The RequestDispatcher interface method sendRedirect() or using the response.sendRedirect() method .
On hearing this , mostly I'am asked what are the differences in these three methods. could any one point out please !!!

Thanx in Advance !
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The forward method works inside the Web container. 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.

RequestDispatcher.forward() and PageContext.forward() are effectively the same. PageContext.forward is a helper method that calls the RequestDispatcher method.
the <jsp:forward..> is a forwarding of your request. What this means is that your request parameters (the request object)_ still remains current and you canstill access all its parameters. On the other hand the sendRedirct() is a NEW REQUEST. you loose all your request parameters. As you might guess <jsp:forward..> is faster. however it does have some problems specially when someone decides to lets say reload a page. The request will be sent again
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx bhart ....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic