bonjour
je debute avec les servlets , je veux faire une simple servlet qui affiche 'hello world' et me permet d'ecrire dans une form, voila le code que j'ai utilisé:
et l'index.jsp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class serve extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String a; a=request.getParameter("ma").toString(); out.println("welcome" +a); out.close(); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; } }
Mais il me génère:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Hello World!</h1> <form action="serve" method="post"> <input type="text" name="ma"> </form> </body> </html>
SVP si quelqu'un a une idée a ce propos merci de bien vouloir m'aider.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 init: deps-module-jar: deps-ear-jar: deps-jar: library-inclusion-in-archive: library-inclusion-in-manifest: compile: compile-jsps: Incrementally deploying http://localhost:80/servlet Completed incremental distribution of http://localhost:80/servlet Incrementally redeploying http://localhost:80/servlet Deploy is in progress... deploy?config=file%3A%2FC%3A%2FDOCUME%7E1%2FADMINI%7E1.SER%2FLOCALS%7E1%2FTemp%2F2%2Fcontext21299.xml&path=/servlet FAIL - Failed to deploy application at context path /servlet C:\Documents and Settings\Administrateur.SERVEUR\Mes documents\NetBeansProjects\servlet\nbproject\build-impl.xml:563: The module has not been deployed. BUILD FAILED (total time: 0 s)
Partager