wood burning stoves 2.0*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request Dispatcher " Watch "Request Dispatcher " New topic
Author

Request Dispatcher

Vishal Gupta
Greenhorn

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.

thanks


SCJP 1.4, SCWCD 1.4
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

What happens when you remove the "\"?

Mark


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

Joined: Mar 06, 2001
Posts: 13459

Check the API for getNamedDispatcher(name)
Vishal Gupta
Greenhorn

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

Joined: Jul 15, 2004
Posts: 21
Thank you David. getNamedDispatcher solved my problem !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request Dispatcher
 
Similar Threads
about sendRedirect
Issue with Struts 2 Dispatcher Result
how to get filename to browser
Creation of Servlet instances
can't print after post doFilter