Skip to content Skip to sidebar Skip to footer

The Requested Resource (/xxx.html) Is Not Available When Redirect

I really do my homework to figure out why but I am still struggling. Please help! I have a Servlet which is running well without any page before today(tomcat 7 & eclipse) Now,

Solution 1:

You need to edit your sendrederct to :

response.sendRedirect("/ProjectName/userhelp.html");

You have response.sendRedirect("/userhelp.html"); arguement to your sendRedirect starts with a forward slash.Which means that 'realative to root of container'.So container builds URL relative to original URL of request.

Your userhelp.html page exits in your project's webcontent.It's relative path from container's root should be /Projectname/userhelp.html.So you need to edit your path in response.sendRedirect.

Edit : Problem is in your servlet mapping as @servletmapping(/) means that anything which comes for this url pattern(/) , should be send to this servlet.So what really happens is that when your servlet is called first time and response.sendredirect() is called ,a new request object is created and as path for it is / , So again your servlet gets called and this recursive process starts.

So solution for this is to change servlet mapping to : @servletmapping(/test) and then call this servlet by calling yourlocalhost/test/ .So when this time redirection is done , Servlet is not called for that.

Post a Comment for "The Requested Resource (/xxx.html) Is Not Available When Redirect"