Writing general information release program with JSP

Time:2022-5-23

Information release interface

Provide an interactive interface for publishing information and call recordmessage JSP program.   

sayMessage.jsp  
< 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=”ymbean.opDb”/>
<form action =recordmessage.jsp 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>
Serial number < tr = “width%” > Display:
<input maxlength=3 name=routeno size=36>
</td></tr>
<tr>
< TD width = “100%” > tour content. When the text exceeds one line, please press enter to wrap</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 database

Connect to Oracle database by calling java bean.   

opDb.java  

package ymbean; // Java package

import java.sql.* ;  

public class opDb {  

public opDb() { }  

public ResultSet executeQuery(String sql)  

{  

ResultSet rs = null;  

Statement lstmt = null;  

try { lstmt = connectdb();  

rs = lstmt.executeQuery(sql);  

System.out.println(“ executeQuery:”+ sql);  

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

return rs;  

}  

public String executeUpdate(String sql)  

{  

ResultSet rs = null;  

Statement lstmt = null;  

try {  

lstmt = connectdb();  

lstmt.executeUpdate(sql);  

System.out.println(“ executeUpdate:”+ sql);  

lstmt.executeUpdate(“ commit” );  

}catch(SQLException ex) {}  

return(“ executeUpdate ok” );  

}  

//Connect 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=“ oracle.jdbc.driver.  

OracleDriver” ;  

Connection lconn;  

try { Class.forName(driverstr);  

lconn=DriverManager.getConnection(connectstr);  

lstmt=lconn.createStatement();  

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

return lstmt;  

}  

}//end opDb.java

Recommended Today

Dynamically add buttons to UIActionSheet in iOS

One, the effect map. Two, the code. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UIActionSheetDelegate> @end RootViewController.m //Click anywhere to pop up UIActionSheet -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@”标题” delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil, nil]; // Add buttons one by one (for example, it can be an array loop) [sheet addButtonWithTitle:@”Item A”]; [sheet addButtonWithTitle:@”Item […]