This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt 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 Introducing JavaFX 8 Programming this week in the JavaFX 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: 189
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
Sheriff

Joined: Jul 29, 2008
Posts: 3698
    
  87

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
 
It's not a secret anymore!