This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes Request Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Request Dispatcher" Watch "Request Dispatcher" New topic
Author

Request Dispatcher

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 176
Hi Everyone
Is it true that , we can not use dispatcher to navigate from a servlet to a Jsp ?



It doesnt work for me, But if i use Redirect then it does work ... why is that ? Thanks!!!
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3179
    
  49

No it's NOT true - you can dispatch from a servlet to JSP, and that's what you should do following MVC. The problem with your code could be the template Next.jsp being not found in the context. Since it is very unlikely that you need to allow your users directly access Next.jsp, put it somewhere in WEB-INF directory, say, for example, as in WEB-INF/templates/next.jsp . When you forward, use the context-relative path, as in getRequestDispatcher("/WEB-INF/templates/next.jsp")


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request Dispatcher