当前位置: 代码迷 >> Java Web开发 >> 注册模块出错 新手
  详细解决方案

注册模块出错 新手

热度:432   发布时间:2016-04-17 00:35:09.0
注册模块出错 新手求助 在线等
错误信息:
org.apache.jasper.JasperException: An exception occurred processing JSP page /adduser.jsp at line 18

15: %> 
16:  
17: <% 
18: String username = new String(request.getParameter("username").getBytes("ISO-8859-1")); 
19: String password = new String(request.getParameter("password").getBytes("ISO-8859-1")); 
20: String profession = new String(request.getParameter("profession").getBytes("ISO-8859-1")); 
21: String email = new String(request.getParameter("email").getBytes("ISO-8859-1"));  


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

java.lang.NullPointerException
org.apache.jsp.adduser_jsp._jspService(adduser_jsp.java:75)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
源码:
<%@page contentType="text/html;charset=gb2312"%> 
<%@page import="java.sql.*"%> 
<%! 
public static final String DBDRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; 
public static final String DBURL = "jdbc:sqlserver://localhost:1433; DatabaseName = e_onlineroom"; 
public static final String DBUSER = "sa" ; 
public static final String DBPASS = "sa" ; 
 
%> 
<%  
Connection conn=null;//定义数据库连接对象 
Statement stmt=null;//定义结果集对象 
ResultSet rs=null ;//定义SQL对象结果集  
%> 
 
<% 
String username = new String(request.getParameter("username").getBytes("ISO-8859-1")); 
String password = new String(request.getParameter("password").getBytes("ISO-8859-1")); 
  String profession = new String(request.getParameter("profession").getBytes("ISO-8859-1")); 
String email = new String(request.getParameter("email").getBytes("ISO-8859-1"));  
%>  
 
<% 
//try 
//{ 
Class.forName(DBDRIVER) ; 
conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;//建立与数据库的连接 
  stmt=conn.createStatement();  
  String sql="select * from huiyuan where username='"+username+"'";  
rs=stmt.executeQuery(sql);  
if(rs.next()){
%>
<script language="javascript">
alert("此用户名已经存在,请重新注册!")
history.back;
</script>
<% 
}else{
String str = "INSERT INTO huiyuan VALUES('"+username+"','"+password+"','"+profession+"','"+email+"')";
stmt.executeUpdate(str);
%>
  <script language="javascript">
alert("注册成功!")
window.location.herf=("../login.jsp");
</script>
<% 
}
rs.close();
stmt.close();
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Mon Sep 24 14:12:50 CST 2018
  • 最近登录:Mon Sep 24 14:12:50 CST 2018
  • 最近登录:Mon Sep 24 14:12:50 CST 2018
  • 最近登录:Mon Sep 24 14:12:50 CST 2018
  • 最近登录:Mon Sep 24 14:12:50 CST 2018