This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In web.xml, it is allowed to disable the invoker (that means call to servlet file directly will be directed to other page). How can I do the same for the jsp page? For example, there's a page login.jsp. The following is part of the web.xml: <servlet> <servlet-name>loginjsp</servlet-name> <jsp-file>/login.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>loginjsp</servlet-name> <url-pattern>/loginPage</url-pattern> </servlet-mapping> I expect that the page can be accessed by calling http://localhost/loginPage only. I don't want people can access the page by http://localhost/login.jsp So I have added the following details in the web.xml: <servlet> <servlet-name>redirectorservlet</servlet-name> <servlet-class>RedirectorServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>redirectorservlet</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> The RedirectorServlet is used for redirect the page to another page. However, in JBuilder, when I start the tomcat server, it generates the following contents in the web.xml and delete my above mapping : <servlet> <servlet-name>debugjsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>jspCompilerPlugin</param-name> <param-value>com.borland.jbuilder.webserverglue.tomcat.jsp.JasperSunJavaComp iler</param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>debugjsp</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> Then how can I disable the call to jsp file directly? Thanks! Stephen
Using tokens . Also remember that the files under WEB-INF folder can not be accessed directly
Joined: Dec 11, 2001
That means placing the jsp file in WEB-INF. Therefore, the jsp pages cannot be viewed by typing the path http://localhost/*.jsp. The page can be accessed by the use of RequestDispatcher from a servlet program or using custom URL set in web.xml. However, it is required to use <jsp:include page="xxx.jsp" /> to include another jsp. However, the jsp is placed in the WEB-INF also, so ServletException is thrown. How can I include the jsp file successfully in this way? i have tried to use absolute path, however, it is still unsuccessful. What should I do? Thanks Stephen