Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher

 
Vishal Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you remove the "\"?

Mark
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the API for getNamedDispatcher(name)
 
Vishal Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remove the "\" it gives me an error and specifically asks to put it back.
 
Vishal Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you David. getNamedDispatcher solved my problem !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic