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

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

<%@ page contentType = "text/html;charset=GB2312" %>
<%@ page import = "java.sql.*" %>






欢迎光临企业办公平台

用户名:
密码:
<% 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(“
”); } 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(“”); out.println(“出错了!”); out.println(“”); }%>

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

你可能感兴趣的:(代码,文案分享,登录界面(jsp),jsp)