This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.