j'ai creé une page jsp pour valider une table de la base donné et l'afficher dans cette page.
et une action pour fair le traitement .
je travaille sous eclipse et myeclipse et tomcat.urgant
voila le code 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
51
52
53
54
<%@ page language="java" pageEncoding="ISO-8859-1"%>
 
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
  <head>
    <html:base />
 
    <title>index.jsp</title>
 
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
 
  </head>
 
  <body>
  <form action="/login">
 <table border="1">
<tr>
<td>Id Software</td>
<td>designation</td>
<td>reference</td>
 
 
</tr>
 
<logic:iterate id="MATERIEL" name="MATERIEL" scope="request">
<tr>
<td><bean:write name="MATERIEL" property="software.MATERIEL_ID"/></td>
<td><bean:write name="MATERIEL" property="software.DESIGN_MAT"/></td>
<td><bean:write name="MATERIEL" property="software.REFERENCE_MAT"/></td>
 
</tr>
</logic:iterate>
</table>
 
</logic:notEmpty>
</form>
 
 
  </body>
</html:html>
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
<< loginAction.java>>
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.apache.struts.action;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
 
import com.apache.struts.form.LoginForm;
 
import java.sql.*;
import java.util.*;
 
/**
 * MyEclipse Struts
 *
 *
 * XDoclet definition:
 * @struts.action attribute="MaterielForm" input="/Index.jsp" parameter="do" scope="request" validate="true"
 * @struts.action-forward name="delet" path="/delet.do" contextRelative="true"
 * @struts.action-forward name="Edit" path="/Edit.do" contextRelative="true"
 */
public class LoginAction extends Action {
 
Connection conn=null;
ResultSet res=null;
Statement st=null;
 
 public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws Exception {
 
 
 
        System.out.println("--------------- MaterielAction ");
        request.setAttribute("MATERIEL",getMateriels());
        return (mapping.findForward("success"));
    }
 
 
/*public void MaConnexion() throws SQLException
{
	try
		{
			Class.forName("oracle.jdbc.driver.OracleDriver");
			String db="jdbc:oracle:thin:@localhost:1521:LOGISOFT";
			conn=DriverManager.getConnection(db,"system","oracle");
		}
	catch(ClassNotFoundException cnfe)
		{
			System.err.println(cnfe);
		}
}*/
public ArrayList getMateriels()
{
 
	try
		{
			Class.forName("oracle.jdbc.driver.OracleDriver");
			String db="jdbc:oracle:thin:@localhost:1521:logisoft";
			conn=DriverManager.getConnection(db,"system","oracle");
 
			ArrayList<LoginForm> list=new ArrayList<LoginForm>();
			if(conn!=null){
				st=conn.createStatement();
				res=st.executeQuery("SELECT * from MATERIEL");
				LoginForm form=null;
				while(res.next()){
					form=new LoginForm();
					form.setMATERIEL_ID(res.getInt(1));
					form.setDESIGN_MAT(res.getString(2));
					form.setREFERENCE_MAT(res.getString(3));
					list.add(form);
				}
			}else System.out.println("Pas de connexion : conn == null");
 
 
			return list;
		}
	catch(Exception e)
	    {
			e.printStackTrace();
			return new ArrayList();
	}
}
 
}
 
/**/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        /**
         * Method execute
         * @param mapping
         * @param form
         * @param request
         * @param response
         * @return ActionForward         */