my dog learned polymorphism
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
JavaRanch » Java Forums » Java » JSP
Bookmark "Request Dispatcher" Watch "Request Dispatcher" New topic

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

Joined: Jul 29, 2008
Posts: 3927

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