• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in forward() method

 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to forward the request to another servlet for that I have written following code



but I'm getting " HTTP Status 404 - /ServletNJspDemo/servlet/WelcomeServlet"
error

I have made entry in web.xml but still getting same error

thanks
 
Vinay Nath
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you map your servlet to /servlet/WelcomeServlet or just /WelcomeServlet in servlet-mapping in web.xml?

swapnel surade wrote:Hi,

I'm trying to forward the request to another servlet for that I have written following code



but I'm getting " HTTP Status 404 - /ServletNJspDemo/servlet/WelcomeServlet"
error

I have made entry in web.xml but still getting same error

thanks
 
kaushik vira
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to run the URL using browser.... check that your URL is valid or not..

Then you get clear idea that, where is gap.
 
Narendhiran Nagarajan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the path of the request dispacher.
If the path starts with
a forward slash (“/”), the Container sees that as “starting from the root of this
web app”. If the path does NOT start with a forward slash, it’s considered
relative to the original request.

If it is a relative path, then remove the slash at the front (** request.getRequestDispatcher("servlet/WelcomeServlet");**)

If you get the request dispatcher from Servlet context, the you cant use the relative path.....that means you must start from the root..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic