• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Forward a request to another Servlet

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am specifying the full path to the target servlet class "Test" from another servlet class.




But I am getting Http 404 error stating The requested resource (/content-type-ex/WEB-INF/classes/com/example/posr/Test) is not available.

Whats wrong with this?
 
Keith Pitty
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to specify the servlet mapping in the argument of getRequestDispatcher.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

Its actually the <url-pattern> element value of the <servlet-mapping> that has to be specified as argument to getRequestDispatcher(String path) method.
 
Keith Pitty
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, to be exact it is the url-pattern of the servlet mapping. Did that fix your problem?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic