Win a copy of Head First Android this week in the Android forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

RequestDispatcher!

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rd=request.getRequestDispatcher(....)
rd.forward(...)
//some lines of code.

why is it that the control returns back to the servlet and the code below forward() is also executed?that should be the case only with include().
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are just calling a method. When it is done it will return. This is the expected behavior.

From the javadoc for those two methods you can see that the difference is what is/isn't done to the Reqeust and Response objects before dispatching the request.
 
kriti sharma
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the code after the call to forward, i throw an exception which should load another error page, which doesnot happen. that is why i am keen to know if the control returns back after forward, coz if it does then the exception must be thrown and the error page must be displayed which is not happening.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Kriti,

The de-facto implementation of RequestDesipatcher object defines the following two things

1. "A call to forward() may be used if *only* if no content has previously sent to the client.

2. "No further data can be sent to a client after tha call to forward has completed.

Assuming your rd.forward() worked succesfully, the request moves out of the current scope and moves on to the forwarded resource.

Why don't you try generating the error page from the resource that this call was forwarded to. (assumption : your architecture should be able to support this)


Cheers!!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic