Search code examples
eclipsejsptomcatweb-inf

Eclipse , Tomcat - The requested resource is not available JSP


Why can't run on server my jsp file putted in webapp/WEB-INF/index.jsp (Tomcat shows Error 404 - The requested resource is not available) but I can run jsp file from webapp/index.jsp folder?

Update

web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
          version="3.0">
<display-name>J2EE Applications Example</display-name>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Test
</body>
</html>

Solution

  • Because, by design, WEB-INF is the only folder of the app that is not accessible from the outside.

    And it's normal: that's where you store the whole code of your webapp, its configuration, etc.

    You really don't want anyone to be able to type /WEB-INF/lib/app.jar in the address bar and download the classes of your webapp.