Bonjour,
Voilà, je débute complètement dans le domaine et j'ai un pb :
J'ai créer un jsp qui fait appel à une servlet.
Si je tape directement l'adresse de ce jsp (www.yubaba.fr\Yubaba\Acceuil) tout va bien, ça marche.
Par contre, si j'essaye d'y accéder avec un line d'une autre fenêtre, ça ne marche pas et Tomcat me renvoie une erreur 500.
Ma servlet :
Mon 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
45
46
47
48
49
50 package web.yubaba.servlets; import java.io.IOException; import java.io.PrintWriter; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @SuppressWarnings("serial") public class ServletBlog extends HttpServlet { //public ArrayList<String> lstFile; //init // GET public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { //lstFile = new ArrayList<String>(); //for (int i=0;i<10;i++) // lstFile.add(String.valueOf(i*10)); String tst="Hello"; tst = "Hello"; // On renvoi les elements de la liste request.setAttribute("nom", tst); //getServletContext ().getRequestDispatcher("/Acceuil.jsp").forward(request, response); getServletContext().getRequestDispatcher("/Acceuil/Acceuil.jsp").include(request, response); } //POST public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { doGet(request,response); } }
mon Web.xml :
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 <%@ 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"> <%@ page import="java.util.ArrayList" %> <% // On récupère la liste //ArrayList lstFile = (ArrayList) request.getAttribute("lstFile"); String nom=(String)request.getAttribute("nom"); %> <html> <head> <title> Blanc 01</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Namo WebEditor(Trial)"> <style><!-- body { background-color:#F3E1D6; color:#000000; font-family:Arial; } h1 { color:#804000; font-family:Arial; font-size:14; } h2 { color:#D96C00; font-family:Arial; font-size:12; } p.namo-list { color:maroon; font-family:Arial; font-size:12; } p.namo-sublist { color:#DD7400; font-family:Arial; font-size:10; } table.namo-table { border-left-color:#FFF1EC; border-top-color:#FFF1EC; border-right-color:#804040; border-bottom-color:#804040; } table.namo-table td { border-left-color:#804040; border-top-color:#804040; border-right-color:#FFF1EC; border-bottom-color:#FFF1EC; } table.namo-table th { background-color:#F8BAA3; border-left-color:#804040; border-top-color:#804040; border-right-color:#FFF1EC; border-bottom-color:#FFF1EC; } span.namo-link, a:link { color:red; text-decoration:underline; } span.namo-visited, a:visited { color:gray; text-decoration:underline; } span.namo-active, a:active { color:#FE8B5A; text-decoration:underline; } li.namo-list1 { list-style-image:url('nav/bullet1.gif'); } li.namo-list2 { list-style-image:url('nav/bullet2.gif'); } --></style> <meta name="namo-theme" content="Theme\Ancient"> </head> <body background="nth_theme_ancient_bg.gif"> <p>Test Array List</p> <% for (int i=0;i<1;i++) { out.println ("<li>" + nom + "</li>\n"); } %> <p> </p> </body> </html>
....
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 <?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> Yubaba</display-name> <servlet> <servlet-name>blog</servlet-name> <servlet-class>web.yubaba.servlets.ServletBlog</servlet-class> </servlet> <servlet-mapping> <servlet-name>blog</servlet-name><url-pattern>/Acceuil/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
Voilà si qqun peut m'aider.... Merci![]()
Partager