JSP可以这样写吗??
没有听说过啊
没有听说过啊
解决方案 »
- http://localhost:8080/打不开
- (急,在线等)webservice的jar包引用问题
- POI该怎么应用在结果集上并能提供下载功能(急急急)
- 为什么加了个jspsmartupload 就会这样
- 查询速度问题!
- 求助在Dreamweaver MX中连接数据库
- 大家救救我,我的jsp文件在ie上执行时,只要是中文就出现乱码,怎么回事呀?
- JSP技术能否实现网页上数据的实时更新,就是实时数据显示。狂散分。
- Tomcat 為甚麼要連結 Apache 一起使用?
- JRUN和IIS4.0连接的问题。英雄救命!!
- 哪位大哥能给我一些java实现文件传输的资料?
- jsp连接池在嵌套查询的时候如何完全关闭?
http://www.enet.com.cn/A20040309292988.html
参考代码:
<%
String strUsername="";
String strUserpwd="";
String strUsersex="";
String strUseremail="";
String strSQL="";
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
strUsername=request.getParameter("txtusername");if(strUsername==null)
{
strUsername="";
}
strUserpwd=request.getParameter("txtpassword");
if(strUserpwd==null)
{
strUserpwd="";
}
strUsersex=request.getParameter("txtsex");
if(strUsersex==null)
{
strUsersex="";
}
strUseremail=request.getParameter("txtemail");
if(strUseremail==null)
{
strUseremail="";
}
strSQL="insert into DBUser(DBUserid,DBUserpwd,DBUsersex,DBUseremail) values ('"+strUsername+"','"+strUserpwd+"','"+strUsersex+"','"+strUseremail+"')";try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce)
{
out.println(ce.getMessage());
}
try{
conn=DriverManager.getConnection("jdbc:odbc:DBUser");
stmt=conn.createStatement();
rs=stmt.executeUpdate(strSQL);
}
catch(SQLException e){
System.out.println(e.getMessage());
}
finally
{
stmt.close();
conn.close();
}
%>