Bonjour,
je travaille actuellement à l'apprentissage de Java EE. Mais, malgré plusieurs heures de recherches et de vérification, je n'arrive pas à afficher ma page jsp situé dans /WEB-INF/test.jsp. Mon fichier jsp est bien dans le dossier WEB-INF.
J'obtiens une erreur 404 lorsque je consulte ma page http://localhost:8080/test/toto
J'utilise eclipse et tomcat 7.0.50.
Merci pour votre aide !
Ma servlet :
Mon web.xml :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package fr.javaee.servlets; import javax.servlet.http.HttpServlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class test extends HttpServlet { public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { this.getServletContext().getRequestDispatcher("/WEB-INF/test.jsp").forward(request, response); } }
Mon jsp :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <?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"> <servlet> <servlet-name>test</servlet-name> <servlet-class>fr.javaee.servlets.test</servlet-class> </servlet> <servlet-mapping> <servlet-name>test</servlet-name> <url-pattern>/toto</url-pattern> </servlet-mapping> </web-app>
Code:
1
2
3
4
5
6
7
8
9
10
11 <%@ page pageEncoding="UTF-8" %> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title> JSP !</title> </head> <body> <p>C'est une page écrite pour du JSP !</p> </body> </html>