Tomcat 6: ¿Puede la página de bienvenida estar dentro de la web-Inf?
Pregunta
Estoy siguiendo este ejemplo para obtener el resorte y en ejecución: http://static.springsource.org/docs/spring-mvc-step-by-step/part2.html
Lo que hacen es mover todos los archivos .jsp dentro de la web-INF, para evitar que los usuarios accedan a ellos directamente ... hasta ahora todo bien. Sin embargo, el servlet tiene una página de bienvenida de index.jsp, y cuando esto se mueve dentro del Dir de Web-INF obtengo errores. No puedo determinar si Tomcat 6 debería permitir que la página de bienvenida esté dentro de la web-Inf o no.
Solución
No se puede acceder directamente a nada dentro de Web-INF, pero primero debe pasar por algo más (generalmente un servlet), que luego reenvía la solicitud internamente al recurso web-INF.
Otros consejos
Estoy intentando el mismo tutorial. El tutorial no dice esto, pero cambié el valor en mi web.xml de "index.jsp" a "/webinf/jsp/index.jsp".
Utilizo dicha técnica (que funcionan para API de servlet> = 2.4):
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
<url-pattern>/index.htm</url-pattern> <<== *1*
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.htm</welcome-file> <<== *2*
</welcome-file-list>
Entonces ya no necesitas redirect.jsp
con:
<% response.sendRedirect("/myproject/MyAction.action"); %>
en noWEB-INF
¡¡directorio!!
Aquí dos blogs con la misma técnica:
- http://technologicaloddity.com/2010/03/25/spring-welcome-file-without-redirect/
- http://wiki.metawerx.net/wiki/howtouseaseServletyourmainwebpage
ACTUALIZAR De SRV.9.10 Welcome Files
Sección de Servlet API 2.4
documentación^
The purpose of this mechanism is to allow the deployer to specify an ordered list of partial URIs for the container to use for appending to URIs when there is a request for a URI that corresponds to a directory entry in the WAR not mapped to a Web component. This kind of request is known as a valid partial request. The use for this facility is made clear by the following common example: A welcome file of `index.html' can be defined so that a request to a URL like host:port/webapp/directory/, where `directory' is an entry in the WAR that is not mapped to a servlet or JSP page, is returned to the client as `host:port/ webapp/directory/index.html'.