My servlet is not workning. Cold someone help me ? you can see thre files her : web.xml, java code, and jsp page. thanks for some help.
web.xml file :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%>
<!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>2) Titre : ecrasee par servlet2</title>
</head>
<body>
<p>2) Par le mappage de cette page jsp et de la servlet MaServlet, il y a ecrasement de ce contenu par a servlet</p>
<p>Pour le vérifier mapper puis démapper par le fichier web.xml sité dans le dossier WebContent</p>
</body>
</html>
java servlet code :
package test.servletpac;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name="MaSecondeServlet")
public class SecondeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public SecondeServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/*ServletContext sc = this.getServletContext() ;
RequestDispatcher rd = sc.getRequestDispatcher("/secondejspservlet.jsp") ;
rd.forward(request, response); */
try
{ this.getServletContext().getRequestDispatcher("/secondejspservlet.jsp").forward(request, response);
}
catch(ServletException ex)
{
System.out.println("Servlet <SecondeServlet> Erreur \"ServletException\" suivante : " + ex.getMessage());
System.out.println("Servlet <SecondeServlet> Erreur \"ServletException\" suivante : " + ex.hashCode());
}
catch(IOException ioex)
{
System.out.println("Servlet <SecondeServlet> Erreur \"IOException\" suivante : " + ioex.getMessage());
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}
jsp file (simple html): <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%>
<!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>2) Titre : ecrasee par servlet2</title>
</head>
<body>
<p>2) Par le mappage de cette page jsp et de la servlet MaServlet, il y a ecrasement de ce contenu par a servlet</p>
<p>Pour le vérifier mapper puis démapper par le fichier web.xml sité dans le dossier WebContent</p>
</body>
</html>