首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jsp登录检测的500-异常

2013-09-11 
jsp登录检测的500-错误我做的jsp登录页面%@ page languagejava importjava.util.*,java.sql.* page

jsp登录检测的500-错误
我做的jsp登录页面
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="GB2312"%>


<html>
  <head>  
   

   
</head>
<body>
  <center><h1>管理员登陆</h1></center><BR/>
  
  <form name="f1" id="f1" action="guanliyuanjiance.jsp" method="post">
  <table border="0" align=center>
  <tr>
  <td>用户:</td>
  <td>
  <input type="text" name="username" id="username" value=""></td>
  </tr>
  <tr>
  <td>密码:</td>
  <td>
  <input type="passwd" name="passwd" id="passwd" value=""></td>
  </tr> 
  <tr>
  <td colspan="2" align="center">
  <input type="submit" value="登陆"></td>
  </tr>
   
  </table>
  <table align="center">
  <a href="index.jsp">返回首页</font></a>
   
  </table>
  </form>
  </body>
  
</html>
检测页面
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'guanliyuanjiance.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
  
  <body>
  <%
  String a=request.getParameter("username");
  String b=request.getParameter("passwd");
  %>
  <%
  //1,加载驱动 
  Class.forName("com.microsoft.jdbc.sqlserver.SqlServerDriver");
  //2,得到连接 
  Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;DatabaseName=userdb","jie","123");
  //3,创建Statement
  Statement stmt=conn.createStatement();
  //4,查询 
  ResultSet rs=stmt.executeQuery("SELECT username from admin WHERE username='"+a+"'");
  //5,执行
  if(rs.next()){
  //说明用户名存在
  if(rs.getString(1).equals(b)){
  //一定合法
  response.sendRedirect("guanliyuan.jsp");
  }else{
  //密码错误
  response.sendRedirect("guanliyuandenglu.jsp");


  }
  }else{
  //用户名不存在
  response.sendRedirect("guanliyuandenglu.jsp");
  }
  // 依次关闭
  rs.close() ;
  stmt.close() ;
  conn.close() ;
  %>
  </body>
  
</html>
可是明明数据库里面建好表,也有一个名字和密码在里面,可是执行时却出现以下错误

org.apache.jasper.JasperException: An exception occurred processing JSP page /guanliyuanjiance.jsp at line 32

29: %>
30: <%
31: //1,加载驱动 
32: Class.forName("com.microsoft.jdbc.sqlserver.SqlServerDriver");
33: //2,得到连接 
34: Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;DatabaseName=userdb","jie","123");
35: //3,创建Statement


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

javax.servlet.ServletException: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SqlServerDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.guanliyuanjiance_jsp._jspService(guanliyuanjiance_jsp.java:128)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SqlServerDriver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1493)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:169)
org.apache.jsp.guanliyuanjiance_jsp._jspService(guanliyuanjiance_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)



求高手指点啊

[解决办法]
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SqlServerDriver
没导驱动包
[解决办法]
就是这个。。。。

探讨

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SqlServerDriver
没导驱动包

[解决办法]
驱动包引入不对
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html

热点排行