문제

I have been stuck up with running hello world program in JSP.When i start my server it showing resource not found exception. please help me to solve this problem. I have mentioned my code below

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>

</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>MySample</display-name>
    <welcome-file-list>

        <welcome-file>index.jsp</welcome-file>

    </welcome-file-list>
</web-app>
도움이 되었습니까?

해결책

From comments above you had placed file in wrong folder.

Put your index.jsp file inside WebContent folder. Do not put in WEB-INF folder.


WebContent folder

  • The mandatory location of all Web resources, including HTML, JSP, graphic files, and so on.
  • If the files are not placed in this directory (or in a subdirectory structure under this directory), the files will not be available when the application is executed on a server.
  • The Web content folder represents the contents of the WAR file that will be deployed to the server. Any files not under the Web content folder are considered development-time resources (for example, .java files, .sql files, and .mif files), and are not deployed when the project is unit tested or published.

Reference

다른 팁

Your Welcome index file should start with "/index.jsp" starting with slash if it is directly inside WebContent directory. If it is inside some dirctory like JSP it should be like /JSP/index.jsp

Your directory structure is important that where you have placed the file and provide that path to welcome-file. hope it helps

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top