File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Use of request dispatcher's include method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Use of request dispatcher Watch "Use of request dispatcher New topic

Use of request dispatcher's include method

lekurwale amol
Ranch Hand

Joined: Apr 22, 2010
Posts: 55
I am having a requirement wherein I want to include a jsp (request dispatcher.include). The jsp sets a value of a text field and control returns to the calling servlet. There after from the servlet, I redirect to some other location
My question : Will the jsp in any case be 'transported' to client? Or it will just be evaluated on server and control returned.
Also, how can I access the text field value set in that jsp?

Ankit Garg

Joined: Aug 03, 2008
Posts: 9280

If you use the original response object to include the JSP, then the content of the JSP will be sent to the client browser (but you can't redirect after that). If you don't want to send the content generated by the JSP to the client, you should use HttpServletResponseWrapper to build a dummy response object to include the JSP. That response object can store the content generated by the JSP in a String. You can also try to find the value of the text field in the String...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: Use of request dispatcher's include method
Similar Threads
requestdispatch - servlet to servlet in iplanet( anyone plzzzzzzz!!!!)
Prevent servlet response from being cache
RequestDispatcher include and forward
How to pass an arrayList from a JSP to a servlet.