probleme d'affichage sur ma jsp
bonjour à tous,
je developpe une appli web
en utilisant le framework struts
j'utilise action +formulaire
ma page web s'affiche avec les jsp
Mon probleme est que struts marche bien (récupere bien l'action )
toutefois je n'arrive pas a afficher les données récupéré dans ma bdd
et l'afficher dans la jsp
le struts-config est bien configuré
si quelqu'un peut m'aider c super j'ai essayé pas mal de configuration
code:
Code:
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
|
jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-layout.tld" prefix="layout" %>
<%@ taglib uri="/WEB-INF/tld/struts-html-el.tld" prefix="html-el" %>
<html-el:html>
<fieldset>
<layout:form action="/FormaLot" method="execute" reqCode="form">
Facility : <html-el:text name="TechnoForm" property="idx" size="30"/>
<html-el:submit/>
</layout:form>
</fieldset>
<br/>
Results :
<table bgcolor='#2D87FF' border='2'background='silver'text='white'cols='9'width='985'>
<td align='center' bgcolor='silver'><strong>YYYY</strong></td>
<td align='center' bgcolor='silver'><strong>XXXX</strong></td>
<td align='center' bgcolor='silver'><strong>WWWW</strong></td>
<tr>
<bean:write name="TechnoForm" property="YYYY"/>
<bean:write name="TechnoForm" property="XXXX"/>
<bean:write name="TechnoForm" property="WWWW"/>
</tr>
</html-el:html> |
action:
Code:
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
|
public class TestFormation extends DispatchAction
{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse res) throws Exception
{
Connection connection = null ;
String forward = "success";
String param1 = request.getParameter("facilityList");
String param2 = request.getParameter("lot_nbmList");
String param3 = request.getParameter("prd_nameList");
DataSource datasource = null;
HttpSession session = request.getSession();
/***************connection BDD*************/
try
{
connection = ((DataSource)(new InitialContext()).lookup("java:jdbc/xxxxxxxxx")).getConnection();
} catch (NamingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
if (request.getParameter("reqcode") != null)
{
if (request.getParameter("reqcode").equals("toto"))
{
System.out.println("toto");
log.warn("TechnoAction: execute starts...\n");
TechnoForm tform = (TechnoForm) form;
tform.setIdx("Veuillez saisir une yyyyy");
tform.setyyyyy("");
tform.setzzzzzz("");
tform.setwwww("");
session.setAttribute("TechnoForm",tform);
}
if (request.getParameter("reqcode").equals("form"))
{
if (datasource != null)
{
try
{
connection = datasource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select yyyyy,zzzzzz,wwwww from fcm_wip where yyyyyyyLIKE 'R8%'"
+ param1 + "'"+ param2 + "'"+ param3 +"'");
while (resultSet.next())
{
param1 = resultSet.getString(1);
param2 = resultSet.getString(2);
param3 = resultSet.getString(3);
}
connection.close();
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
return mapping.findForward(forward);
}
} |