简单的jsp代码(登录界面)

简单的jsp代码
我们用jsp写一个简单的登录页面,大家参考一下

<%@ page contentType = "text/html;charset=GB2312" %>
<%@ page import = "java.sql.*" %>
<html>
<head>
<title></title>
</head>
<body bgcolor=LightBlue>
<div align="center">
<br>
<H1>欢迎光临企业办公平台</H1>
<form name="form1" method="post" action="" target="_self">
<table width="90%">
<tr>
<td width="50%" height="30" align="right">用户名:</td>
<td width="50%" height="30" align="left"> <input type="text" name="UserName"></td>
</tr>
<tr>
<td width="50%" height="30" align="right">密码:</td>
<td width="50%" height="30" align="left"> <input type="password" name="UserPassword"></td>
</tr>
<td width="100%" height="40" align="center" colspan="2">
<input type="submit" name="sub" value="登录">  
</td>
</tr>
</table>
</form>
</div>
<% try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:a","root","database1");
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = null;
String name =new String(request.getParameter("
UserName").getBytes(“8859_1”));
String passwd =new String(request.getParameter("
UserPassword").getBytes(“8859_1”));
if(String_sql==null)
{
out.println("登陆名不可以为空");
out.println(“<HR>”);
}
else{
String_sql="select * from student where name ="+name+" and password="+psword+;
rs=stmt.executeQuery(String_sql)
while(rs.next())
{ out.println("登陆成功!");
out.println("您的用户名是:"+name)
out.println("您的密码是:"+password);
rs.close();
stmt.close();
conn.close();}
}
Catch( Exception e )
{out.println(“<font color=red size=5><B>”);
out.println(“出错了!”);
out.println(“</B></font>”);
}%>
</body>
</html>

注:jsp是嵌套在HTML中的,大家可以用MyEclipse或者eclipse或者dw都可以实现代码的调试。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值