SoFunction
Updated on 2025-04-07

Writing a general information publishing program in JSP

Information release interface

Provides an interactive interface for publishing information and calls the program.

  
<HTML> <HEAD> <TITLE> Information Release</TITLE>
<META content = "text/html; charset=GB2312" http-equiv = Content-Type>
<LINK href ="css_01.css" rel = stylesheet>
<META content = "MSHTML 5.00.3103.1000" name =GENERATOR> </HEAD>
<BODY>
<% @ page contentType=“ text/html; charset=GB2312”% >  

<% @ page language=“ java” import=“ java .sql .*”% >  

<jsp: usebean id ="rencommend" scope="page" class=""/>
<form action = method =post name=sign>
<input name=dtkey type=hidden value=ta_routes>
<table bgcolor=#d5e8fd border=0 cellspacing=1 width="97%">
<tbody>
<tr> <td nowrap width="45%" height="185">
<div align=left>
<table bgcolor=#d5e8fd border=0 cellspacing=1 width="100%">
<tbody>
<tr> <td nowrap width="100%" > Line name:
<input maxlength=100 name = routename size=36>
</td>
</tr>
<tr><td nowrap width="100%">Show serial number:
<input maxlength=3 name=routeno size=36>
</td></tr>
<tr>
<td width="100%" >Tour content. When the text exceeds one line, please type Enter key to wrap the line</td>
</tr>
<tr><td width="100%" height="162">
<TEXTAREA cols=55 name =c04 rows=9>
</TEXTAREA>
</TD>
</TR></TBODY></TABLE></DIV></TD></TR>
<TR><TD align=middle colspan=2 nowrap>
<input name=cmdcommit type=submit value="submit">
</td></tr></tbody></table>
</form></center>
<div></div></body></html>  


Connect to the database

Connect to the Oracle database by calling Java Bean.

  

package ymbean; // java package

import .* ;  

public class opDb {  

public opDb() { }  

public ResultSet executeQuery(String sql)  

{  

ResultSet rs = null;  

Statement lstmt = null;  

try { lstmt = connectdb();  

rs = (sql);  

(“ executeQuery:”+ sql);  

} catch(SQLException ex) { return(null); }  

return rs;  

}  

public String executeUpdate(String sql)  

{  

ResultSet rs = null;  

Statement lstmt = null;  

try {  

lstmt = connectdb();  

(sql);  

(“ executeUpdate:”+ sql);  

(“ commit” );  

}catch(SQLException ex) {}  

return(“ executeUpdate ok” );  

}  

//Connect the database

public Statement connectdb()  

{ Statement lstmt=null;  

Connection conn=null;  

final String connect_string=“ jdbc:oracle:thin:scott/[email protected]:1521:test” ;  

final String driver_string=“ .  

OracleDriver” ;  

Connection lconn;  

try { (driverstr);  

lconn=(connectstr);  

lstmt=();  

} catch (Exception e) { return(null);}  

return lstmt;  

}  

}//end