views:

1124

answers:

4

in web.xml i set my welcome file to a jsp within web.xml

<welcome-file>WEB-INF/index.jsp</welcome-file>

inside index.jsp i then forward on to a servlet

<% response.sendRedirect(response.encodeRedirectURL("myServlet/")); %>

however the application tries to find the servlet at the following path

applicationName/WEB-INF/myServlet

the problem is that web-inf should not be in the path. If i move index.jsp out of web-inf then the problem goes but is there another way i can get around this?

A: 

As I understand it, WEB-INF is a special folder containing configuration and classes used by your JSPs, you shouldn't put code intended for direct serving inside it.

Anyhow, have you tried /myServlet?

Vinko Vrsalovic
A: 
<% response.sendRedirect(response.encodeRedirectURL("/myServlet/")); %>`

since the jsp is served from the WEB-INF directory the servlet url is also resolved from that relative path. adding a / before will resolve the url from the context root

shyam
A: 

Have you tried to do it with the absolute path ?

response.sendRedirect(response.encodeRedirectURL("/myServlet/"));
axk
A: 

ya thats my understanding too,

but when you use the welcome-file your not actually hiting index.jsp directly, when you hit the applications context root it looks inside web.xml and checks if you have set a welcome-file and if so directs you to it, so your not actually hiting the jsp directlt, is the correct?

combi001