reg.jsp表单提交后,由regok.jsp验证,若没有重名,就将数据插入到数据库user表中。然后将页面转到index.jsp。但是老是出现“Internet Explorer 无法显示该网页”的错误。大侠帮帮忙,这是为什么?<%@ page contentType="text/html;charset=gb2312" %>
<%@ include file="conn.jsp"%>
<%@ page import="java.sql.*"%>
<%! String face,nick,code,code1,sex,email,qq;%>
<%
//从注册页面获得用户注册信息
    String nich= request.getParameter("nich");
String mima= request.getParameter("mima");
String sex= request.getParameter("sex");
String email= request.getParameter("email");
String qq=request.getParameter("qq");
String truename=request.getParameter("truename");
String sidclass=request.getParameter("sidclass");
String cardnum=request.getParameter("cardnum");
String edudegree=request.getParameter("edudegree");
String nationality=request.getParameter("nationality");
String intro=request.getParameter("intro");
        
String sqlUser = "select * from user  where name='" +nich+"'";
rs.next();
if(rs != null){
response.sendRedirect("reg.jsp?msg=用户已经存在,请重新选择用户名进行注册!");
}else{
//新用户记录
Statement stmt_ADD=conn.createStatement();
String Sql="insert into user(nich,mima,truename,sidclass,"
+ "cardnum,sex,edudegree,"
+ "nationality,email,qq,"
+ "intro) values ('" + nich + "','"
+ mima+"','"+ truename+"','"+sidclass+"','"+cardnum+"','"
+ sex+"','"+edudegree+"','"
+ nationality
+ "','" + email + "','" + qq + "','"
+ intro+"')";
int add1=stmt_ADD.executeUpdate(Sql);
if (add1>0){
System.out.print("用户:["+ nich +"] 注册成功");
session.setAttribute("loginuser",nich);
response.sendRedirect("index.jsp");
}else {
System.out.print("注册失败,请重新注册!");
response.sendRedirect("reg.jsp");
}     
stmt_ADD.close();

stmt.close() ; 
%>

解决方案 »

  1.   

    tomcat 启动了吗
    你把项目配置到tomcat里面了吗?
      

  2.   

    都配置好了,其它页面都能正常运行。就是reg.jsp一提交后,就出现“Internet Explorer 无法显示该网页”这种情况。
      

  3.   

    先输出一个sql语句,然后再输出add1,看是不是你想要的
      

  4.   


    在小脚本里面是直接用内置对象out吧
    System.out.print();不行
    改为out.print();
      

  5.   

    这个页面连接的是access数据库,我刚才仔细看看了tomcat的error提示,说是无法连接数据库:No suitable driver。我写的conn.jsp的内容是:<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%>
    <%
    String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=f:/新建文件夹/myjsp/WebRoot/7dy311/db1.mdb"; 
    Connection conn=null;
    Statement stmt=null;
    ResultSet rs=null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    conn=DriverManager.getConnection("url","","");
    }
    catch(ClassNotFoundException cnfex) {
    System.err.println("装载JDBC/ODBC驱动程序失败。");
    cnfex.printStackTrace();
    System.exit(1);
    }
    catch(SQLException sqlex) {
    System.err.println("无法连接数据库");
    sqlex.printStackTrace();
    System.exit(1);
    }
    try {
    stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    }
    catch (SQLException sqlex){
    sqlex.printStackTrace();
    }
    %>大家帮我看看是不是错了啊。谢了啊。
      

  6.   

    String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+request.getRealPath("/")+"7dy311/db1.mdb";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      

  7.   

    回答cjdxhc:都按你说的改了,但是还是不行,总是无法连接数据库,找不到合适的驱动
      

  8.   

    在 odbc数据源 中配置了没?
      

  9.   

    你尝试连接其他数据库看看行不行,比如MYSQL的,还有确认驱动是否正确
      

  10.   


    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        conn=DriverManager.getConnection("url","","");你着是桥连接,数据源配置好了没?
      

  11.   

    对不起,没看见10搂的
    conn=DriverManager.getConnection("url","数据源名");
      

  12.   

    我将conn.jsp改写成如下代码了:<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%>
    <% 
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
    String url="jdbc:odbc:wysp"; 
    String username=""; 
    String password="";
    Connection conn=null; 
    Statement stmt=null;
    ResultSet rs=null; 
    try{
    conn=DriverManager.getConnection(url,username,password);
    }
    catch(SQLException sqlex) {
    System.err.println("无法连接数据库");
    sqlex.printStackTrace();
    System.exit(1);
    }
    try {
    stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    }
    catch (SQLException sqlex){
    sqlex.printStackTrace();

    %>这样在运行regok.jsp时不出现找不到数据库的错误了,但出现
    exception org.apache.jasper.JasperException: An exception occurred processing JSP page /regok.jsp at line 2017:  String intro=request.getParameter("intro");
    18:          
    19:  String sqlUser = "select * from user  where name='" +nich+"'";
    20:  rs = stmt.executeQuery(sqlUser); 
    21:  rs.next();
    22:  if(rs != null){
    23:  response.sendRedirect("reg.jsp?msg=用户已经存在,请重新选择用户名进行注册!");
    简直要崩溃了,我是自学jsp做毕业设计的,但没想到困难重重。请各位大哥们赶紧帮帮忙啊!!