This article here for your friends to provide a free JSP complete file Upload Oh, if you are looking at this file upload code not to come in to see it, good crap not say much.
public void Reset (Actionmapping actionmapping,
HttpServletRequest httpservletrequest) {
}
}
JSP page corresponding to Actionform
Taglib uri= "/web-inf/struts-html.tld" prefix= "html"%>
<%@ taglib uri= "/web-inf/struts-bean.tld" prefix= "Bean"%>
<%@ taglib uri= "/web-inf/struts-logic.tld" prefix= "logic"%>
<%@ page contenttype= "text/html; Charset=utf-8 "%>
<%request.setcharacterencoding ("gb2312");%>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<link href= ". /css/main.css "rel=" stylesheet "type=" Text/css ">
<title>add trainplan</title>
<body>
<table width= "border=" "0" align= "center" cellpadding= "0" cellspacing= "0" class= "Tabletoolbar" >
<tr>
<TD class= "Tabletitletext" ><div align= "center" class= "Tabletitletext" >add trainplan</div></td >
</tr>
</table>
<!--dwlayouttable-->
<table width= "border=" "0" align= "center" cellpadding= "7" cellspacing= "0" class= "Inputframemain" >
<tr>
<TD width= "3%" nowrap> </td>
<TD width= "11%" nowrap><strong>title</strong></td>
<TD width= "22%" Nowrap><TD width= "22%" Nowrap><TD width= "10%" nowrap><div align= "center" ></div></td>
</tr>
<tr>
<TD nowrap> </td>
<TD Nowrap><strong>post index</strong></td>
<TD nowrap>
</td>
<TD nowrap><div align= "center" ><strong>Issuer</strong></div></td>
<TD nowrap>
<TD height= "colspan=" 8 "nowrap><div align=" center "></div> <div align=" center ">
<tr>
</tr>
</div></td>
</tr>
</table>
<br>
<table width= "595" border= "0" align= "center" cellpadding= "7" cellspacing= "0" class= "Inputframemain" >
Train Plan Content
<tr>
<TD width= "10%" Nowrap><strong>trainplan content</strong>:<span class= "InputAreaCell" >< Strong><br>
</strong></span></td>
<TD width= "90%" >
</tr>
<tr>
<TD height= "colspan=" 8 "nowrap><div align=" center "></div> <div align=" center ">
</div></td>
</tr>
</table>
<br>
<table width= "610" border= "0" align= "center" cellpadding= "7" cellspacing= "0" class= "Inputframemain" >
Accessory
<tr>
<TD width= "595" ><span class= "Inputareacell" ><strong>accessory1
</div></td>
</tr>
</table>
</body>
Action page,
Package tester.business.maitain;
Import Tclcc.tester.util.Selector;
Import org.apache.struts.action.*;
Import javax.servlet.http.*;
Import java.util.*;
Import Org.apache.struts.upload.FormFile;
Import java.io.*;
try {
Trainplan.setp_accessory (p_accessory);
Trainpdao.addtrainplan (Trainplan)//Call Database Insert method
SYSTEM.OUT.PRINTLN ("Success");
catch (Exception ex) {
}
Httpservletrequest.setattribute ("Trainplain", Trainplan);
Return (Actionmapping.findforward ("trainplancreated"));
}
}
Package tester.business.maitain;
Import Tclcc.tester.business.maitain.Trainplan;
Import Tclcc.tester.util.DBConn;
Import java.sql.*;
Import java.util.*;
public class Trainplandao {
Private Dbconn dbconn = null;
PRIVATE Connection conn = null;
private static final String add_trainplan=
"INSERT into Ks_trainplan (p_id,p_title,issue_time,issuer,p_content,p_accessory) VALUES (Lpad Seq_p_id.nextval,10,´ 0´),?,?, to_date (?, ´yyyy-mm-dd´),?,?,?) ";
Private final static String update_trainplan=
"UPDATE Ks_trainplan set P_id=?,p_title=?,post_index=?,issue_time=to_date (?, ´yyyy-mm-dd´), Issuer=?,p_content=?,p_ Accessory=? where p_id=? ";
/**
* Get a connection a DB pool
* @return Connection
*/
Public Trainplandao () {
try {
Dbconn = new Dbconn ();
conn = Dbconn.getconnection ();
catch (Exception ex) {
Ex.printstacktrace ();
}
}
/**
* Add a row into DB
* @param examinee examinee
* @throws SQLException
*/
public void Addtrainplan (Trainplan Trainplan) throws SQLException {
PreparedStatement pstmt = null;
try {
pstmt = Conn.preparestatement (Add_trainplan);
Pstmt.setstring (1, Trainplan.getp_title ());
Pstmt.setstring (2, Trainplan.getissue_time ());
Pstmt.setstring (3, Trainplan.getissuer ());
Pstmt.setstring (4, Trainplan.getp_content ());
Pstmt.setstring (5, Trainplan.getp_accessory ());
Pstmt.executeupdate ();
catch (SQLException ex) {
Ex.printstacktrace ();
finally {
try {
Pstmt.close ();
Conn.close ();
catch (SQLException Ex1) {
}
}
}
/**
* Remove a row from DB
* @param Trainplan Trainplan
* @throws SQLException
*/
public void Removetrainplan (Trainplan Trainplan) throws SQLException {
This.removetrainplan (trainplan.getp_id ());
}
/**
* Remove a row from DB
* @param p_id int
* @throws SQLException
*/
public void Removetrainplan (int p_id) throws SQLException {
Statement stmt = null;
try {
stmt = Conn.createstatement ();
Stmt.execute ("DELETE from Ks_trainplan WHERE p_id=" + p_id);
catch (SQLException ex) {
Ex.printstacktrace ();
throw new SQLException ("Sqlexction On:TrainPlanDAO.removeExaminee ()");
finally {
try {
Conn.close ();
catch (SQLException Ex1) {
Ex1.printstacktrace ();
}
}
}
/**
* Update a row
* @param examinee examinee
* @throws SQLException
*/
public void Updatetrainplan (Trainplan Trainplan) throws SQLException {
PreparedStatement pstmt = null;
try {
Update_trainplan = Update_trainplan + "where p_id =" + trainplan.getp_id (); The condition need modification
pstmt = Conn.preparestatement (Update_trainplan);
Pstmt.setint (1, trainplan.getp_id ());
Pstmt.setstring (2, Trainplan.getp_title ());
Pstmt.setint (3, Trainplan.getpost_index ());
Pstmt.setstring (4, Trainplan.getissue_time ());
Pstmt.setstring (5, Trainplan.getissuer ());
Pstmt.setstring (6, trainplan.getp_content ());
Pstmt.setstring (7, Trainplan.getp_accessory ());
Pstmt.setint (8,trainplan.getp_id ());
Pstmt.executeupdate ();
}/*catch (SQLException ex) {
Ex.getstacktrace ();
throw new SQLException ("Sqlexction On:TrainPlanDAO.updateExaminee ()");
} */
catch (SQLException Sqle) {
Todo
{
System.err.println ("Exception occoured:message:" +sqle.getmessage ());
System.err.println ("SQL State:" +sqle.getsqlstate ());
SYSTEM.ERR.PRINTLN ("Vendor Code:" +sqle.geterrorcode () + "---------------");
while ((Sqle=sqle.getnextexception ())!=null);
}finally {
try {
Conn.close ();
catch (SQLException Ex1) {
Ex1.printstacktrace ();
}
}
}
/**
* Get all of record from DB
* @throws SQLException
* @return Collection
*/
Public Collection Getal L () throws SQLException {
Statement stmt = null;
ResultSet rs = null;
Trainplan Trainplan = null;
Collection list = null;
try {
stmt = Conn.createstatement ();
rs = Stmt.executequery ("SELECT * from Ks_trainplan");
List = new ArrayList ();
while (Rs.next ()) {
Trainplan = new Trainplan ();
TRAINPLAN.SETP_ID (Rs.getint ("p_id"));
Trainplan.setp_title (rs.getstring ("P_title"));
Trainplan.setpost_index (Rs.getint ("Post_index"));
Trainplan.setissue_time (rs.getstring ("Issue_time"));
Trainplan.setissuer (rs.getstring ("issuer"));
Trainplan.setp_content (rs.getstring ("p_content"));
Trainplan.setp_accessory (rs.getstring ("p_accessory"));
List.add (Trainplan);
}
catch (SQLException ex) {
finally {
try {
Conn.close ();
catch (SQLException Ex1) {
Ex1.printstacktrace ();
}
return list;
}
}
public static String toString (Trainplan Trainplan) {
return Trainplan.getp_title ();
}
/**
* For Test
* @param args string[]
*/
}