How to properly put JSPs in the WEB-INF folder?

You can put your JSP in

WEB-INF/jsp 

folder and access that JSP using servlet.

Create login.jsp and then access that JSP using preloginservlet.java. This servlet redirects to login.jsp which is in the WEB-INF/jsp folder.


Its not a standard practice or valid as per the J2EE spec (I know using most of the java Web development frameworks like Struts, Spring MVC, Stripes you can do this). As per the spec, all our publicly accessibly pages should be out side of WEB-INF. But if you want the pages to be in web-inf, what you can do is to create a servlet along the lines of a controller servlet and forward the requests to jsp pages from your servlet and those pages can be in WEB-INF, and there is no special configuration that can be done to do this.