Citation:
package example;
import com.opensymphony.xwork2.ActionSupport;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Acceuil extends ActionSupport
{
public static String nom;
String connexion ()
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String connectionString= null;
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
try
{
connectionString ="jdbc:sqlserver://CSS;database=Bilan Prospectif;user=wael;password=09111985";}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
conn = DriverManager.getConnection(connectionString);
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT DESIGNATION_CAPITAL FROM CAPITAL where ID_CAPITAL=11");
while (rs.next())
{
nom=(rs.getString("DESIGNATION_CAPITAL"));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
return nom;
}
private String NomDocument;
private String DescriptionDocument;
private String LogoEntreprise;
public void setNomDocument(String NomDocument)
{
this.NomDocument=NomDocument;
}
public String getNomDocument()
{
return NomDocument;
}
public void setDescriptionDocument(String DescriptionDocument)
{
this.DescriptionDocument=DescriptionDocument;
}
public String getDescriptionDocument()
{
return DescriptionDocument;
}
public void setLogoEntreprise(String LogoEntreprise)
{
this.LogoEntreprise=LogoEntreprise;
}
public String getLogoEntreprise()
{
return LogoEntreprise;
}
public String execute()
{
String a;
Acceuil ac= new Acceuil();
a=ac.connexion();
ac.setNomDocument(a);
return SUCCESS;
}
}
la vue Acceuil.JSP
Citation:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title><s:text name="Page d'Acceuil"/></title>
</head>
<body>
<h1>TEST DE LA PAGE ACCEUIL</h1>
<br>
<s:bean name="java.util.Date" var="today"/> Today (original format): <s:property value="#today"/>
<br>
<br>
<br>
<br>
<br>
<h1>
on dit: <br>
Salut<s:property value="NomDocument"/>
</h1>
</body>
</html>
merci d'avance