I've followed the tutorial on youtube channel "Java Brains" link : https://www.youtube.com/watch?v=gU0RebsaFzQ&t=10s and got stuck while running a servlet file . I am getting this error message :
HTTP Status [404] – [Not Found]
Type Status Report
Message /SimpleServletProject/servlet/org.altamash.careersix.SimpleServlet
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
My simple index.html is :
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Simple Web Application</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
web.xml file is as :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU" xmlns="http://ift.tt/19L2NlC" xsi:schemaLocation="http://ift.tt/19L2NlC http://ift.tt/1drxgYl" id="WebApp_ID" version="3.1">
<display-name>SimpleServletProject</display-name>
<servlet>
<servlet-name>SimpleServlet</servlet-name>
<servlet-class>SimpleServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SimpleServlet</servlet-name>
<url-pattern>/SimpleServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
and finally my servlet file SimpleServlet.java is as follows :
package org.altamash.careersix;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class SimpleServlet
*/
@WebServlet("/SimpleServlet")
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Hello from doGet method");
response.setContentType("text/html;charset=UTF-8");
PrintWriter writer = response.getWriter();
writer.println("<h3>Hello in HTML</h3>");
}
}
Please guys Help me to solve this problem :( .. Thanks .
Aucun commentaire:
Enregistrer un commentaire