aspose file tools
The moose likes Servlets 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 Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request Dispatcher " Watch "Request Dispatcher " New topic

Request Dispatcher

Vishal Gupta

Joined: Jul 15, 2004
Posts: 21
I am using the following snippet in my code:

RequestDispatcher dispatcher=this.getServletConfig().getServletContext().getRequestDispatcher("\NewServlet");

This servlet is in a MVC architecture setting. So everytime I try to redirect, the controller tries to find the "NewServlet" in the root directory of the application.
I even tried using the absolute path..still does not work.

What is the best way for Servlet to Servlet communication? I do not want to hard code a URL.


SCJP 1.4, SCWCD 1.4
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17260

What happens when you remove the "\"?


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Check the API for getNamedDispatcher(name)
Vishal Gupta

Joined: Jul 15, 2004
Posts: 21
If I remove the "\" it gives me an error and specifically asks to put it back.
Vishal Gupta

Joined: Jul 15, 2004
Posts: 21
Thank you David. getNamedDispatcher solved my problem !!
I agree. Here's the link:
subject: Request Dispatcher