Topic: jsp登陆数据库判断的问题 |
Print this page |
1.jsp登陆数据库判断的问题 | Copy to clipboard |
Posted by: nogod Posted on: 2004-10-11 12:55 <%@ page import="java.sql.*"%> <% String xingming,mima; xingming=request.getParameter("name"); mima=request.getParameter("pasd"); if(xingming == null or mima == null) { response.sendRedirect ("error.jsp"); } if (xingming != null and mima != null) { try{ String url="jdbc:odbc:home"; Connection conn; Class.forName("sun.jdbc.odbc.JdbcOddbcDriver"); conn=DriverManager.getConnection(url,"",""); Statement stmt = conn.createStatement(); ResultSet rs; String cx="select * from admin where name='"+xingming+"' and pasd='"+mima+"'"; rs=st.executeQuery(cx); if(rs.next()) { if(xingming.equals("0")) { response.sendRedirect ("main.jsp"); } else { response.sendRedirect("error.jsp"); } } } catch(Exception e) { out.println("执行操作失败"); } } %> 我的意思是当 用户名和密码有一个为空的时候,让它出现error.jsp,当都不为空的时候,先检查数据库里有没有这个名字和密码,然后,再判断。我的所有的代码都是下在.jsp文件里的,没用bean文件,数据库都能成功连接了。可是为什么老是出这个样的错误呢。 C:\Program Files\work\Standalone\localhost\_\home\main$jsp.java:67: ')' expected. if(xingming == null or mima == null) ^ An error occurred between lines: 12 and 50 in the jsp file: /home/main.jsp Generated servlet error: C:\Program Files\work\Standalone\localhost\_\home\main$jsp.java:71: ')' expected. if (xingming != null and mima != null) ^ 2 errors, 1 warning |
2.Re:jsp登陆数据库判断的问题 [Re: nogod] | Copy to clipboard |
Posted by: nothing Posted on: 2004-10-11 13:16 should be: if(xingming == null || mima == null) { response.sendRedirect ("error.jsp"); } if (xingming != null && mima != null) { or ==> || and ==> && |
3.Re:jsp登陆数据库判断的问题 [Re: nogod] | Copy to clipboard |
Posted by: nogod Posted on: 2004-10-11 20:25 谢谢楼上的,学的语言太多了,把vb的能到java里来了,让你见笑了。 |
4.Re:jsp登陆数据库判断的问题 [Re: nogod] | Copy to clipboard |
Posted by: chengbd Posted on: 2004-10-12 15:56 学多了确实容易混淆 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |