bonjour,

j'ai commencé par un exemple simple avec:

1 jsp un bouton valider avec pour action servlet coucou

qui doit afficher coucou

pris independemment cela fonctionne c'est a dire lorsque je fait run as (sous eclipse) du jsp affiche le bouton ok puis ensuite la servlet coucou run as il affiche bien coucou mais ensemble le formulaire s'affiche je clique sur le bouton valider il devrait m afficher coucou et la j'ai un message d'erreur

http 404 requested resource servletcoucou is not available

voici mon code :



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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
 
 
/myprod/WebContent/WEB-INF/index.jsp
 
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>
<form action = "servlet/ServletCoucou" method = "get">
<input type = "submit" value = "Valider">
</form>
</body>
</html>
 
 
/myprod/WebContent/WEB-INF/web.xml
 
web.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>
	myprod</display-name>
	<servlet>
		<description>
		</description>
		<display-name>
		ServletCoucou</display-name>
		<servlet-name>ServletCoucou</servlet-name>
		<servlet-class>
		pack1.ServletCoucou</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>ServletCoucou</servlet-name>
		<url-pattern>/ServletCoucou</url-pattern>
	</servlet-mapping>
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>
 
 
/myprod/src/pack1/ServletCoucou.java
 
 
 
ServletCoucou.java
 
 
package pack1;
 
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
 
 public class ServletCoucou extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
 
 
	public ServletCoucou() {
		super();
	}   	
 
 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	java.io.PrintWriter out=response.getWriter();
	out.println("coucou");
 
 
	}  	
 
 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 
	}   	  	    
}

je ne sais pas pourquoi cela ne fonctionne pas

merci pour votre aide