主题:一个很简单的问题求救用户登陆!!!!!!急急急!!
代码如下:
………………
<FORM name=form action=login.jsp method=post>
…………
login.jsp
<%@page contentType="text/html; charset=gb2312" language="java" %>
<%@ page import="java.sql.*" %>
<%!
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
%>
<%
String user=request.getParameter("username");
String pwd=request.getParameter("password");
user.trim();
pwd.trim();
boolean success=false;
boolean valid=true;//判断用户是否重复登陆
String strSQL="select * from admin where username = '" + user+ "' and password = '" + pwd+ "'";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程式类别
Connection con = DriverManager.getConnection("jdbc:odbc:test3"); //建立资料库连线
//建立Statement变量, 并设定记录指标类型为可前後移动
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(strSQL); //建立ResultSet(结果集)变量,并执行SQL语句
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
if(rs.next())//判断用户输入的用户名和密码是不是admin和admin是就跳到upload.htm页面
{
success=true;
response.sendRedirect("http://www.163.com");
}
else
{ success=false;
response.sendRedirect("upload.htm");
}
rs.close(); //关闭ResultSet对象
stmt.close(); //关闭Statement对象
con.close(); //关闭Connection对象
%>
运行是出现如下的错误:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:207)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
………………
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Apache Tomcat/4.1.31
………………
<FORM name=form action=login.jsp method=post>
…………
login.jsp
<%@page contentType="text/html; charset=gb2312" language="java" %>
<%@ page import="java.sql.*" %>
<%!
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
%>
<%
String user=request.getParameter("username");
String pwd=request.getParameter("password");
user.trim();
pwd.trim();
boolean success=false;
boolean valid=true;//判断用户是否重复登陆
String strSQL="select * from admin where username = '" + user+ "' and password = '" + pwd+ "'";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程式类别
Connection con = DriverManager.getConnection("jdbc:odbc:test3"); //建立资料库连线
//建立Statement变量, 并设定记录指标类型为可前後移动
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(strSQL); //建立ResultSet(结果集)变量,并执行SQL语句
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
if(rs.next())//判断用户输入的用户名和密码是不是admin和admin是就跳到upload.htm页面
{
success=true;
response.sendRedirect("http://www.163.com");
}
else
{ success=false;
response.sendRedirect("upload.htm");
}
rs.close(); //关闭ResultSet对象
stmt.close(); //关闭Statement对象
con.close(); //关闭Connection对象
%>
运行是出现如下的错误:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:207)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
………………
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Apache Tomcat/4.1.31