Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP status - 404 Resource not found exception in JSP [duplicate]

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>
like image 981
Giridharan Avatar asked Apr 03 '14 06:04

Giridharan


2 Answers

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

  • Dynamic Web projects and applications directory structure in Eclipse IDE
like image 134
Aniket Kulkarni Avatar answered Sep 22 '22 23:09

Aniket Kulkarni


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

like image 24
Karthigeyan Vellasamy Avatar answered Sep 22 '22 23:09

Karthigeyan Vellasamy