How to generate a link in JSP to JSP file located into WEB-INF folder
Joined: Dec 07, 2011
My question is: is it possible to generate a link to a JSP situated into WEB-INF folder without use a servlet class.
Here my configuration:
Into index.jsp, I include /WEB-INF/jsp/main.jsp.
Into main.jsp, I have a link to about.jsp.
But how to generate this link ?
href="about.jsp" doesn't work, it is normal because folder WEB-INF is protected by tomcat.
I think i need to use pageContext.getServletContext(), but I don't know how to use it.
You can't link to anything inside the WEB-INF directory directly. In your situation I see two options:
1) Move these JSP files outside of the WEB-INF directory. Since you need to link to them, and therefore they need to be publicly available, this would be my choice.
2) Create a servlet entry with matching URL mapping entry inside your web.xml file. This will give the JSPs an "alias" that can be reached through the URL(s) specified in the URL mapping.