| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5533 人关注过本帖
标题:login.jsp中按下登陆 form跳转时出现500错误
只看楼主 加入收藏
Alikce
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2015-6-11
结帖率:50%
收藏
 问题点数:0 回复次数:1 
login.jsp中按下登陆 form跳转时出现500错误
<%@ page language="java" import="java.util.*,java.sql.*"
    pageEncoding="gbk"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";

    request.setCharacterEncoding("gb2312");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:odbc:teashop",
            "sa", "");
    Statement stmt = conn.createStatement(
            ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = null;//声明结果集rs
    //--------------------------------------------------------
    String op = request.getParameter("op");
    if (op != null && op.equals("exit")) {
        session.removeAttribute("userid");
        session.removeAttribute("cart");
        response.sendRedirect("cust/index.jsp");
    }

    if (op != null && op.equals("login")) {
        String s_userid = request.getParameter("userid");
        String s_password = request.getParameter("password");
        String s_select = "select * from user where userid='"
                + s_userid + "' and password='" + s_password + "'";
        rs = stmt.executeQuery(s_select);
        if (rs.next()) {
            //有用户信息
            session.setAttribute("userid", s_userid);
            response.sendRedirect("index.jsp");
        } else {
            //无此用户信息
            String temp = "您输入的用户名或密码错误,请重新输入。返回!";
            temp = (temp.toString(), "gbk");
            response.sendRedirect("error.jsp?errormessage=" + temp);

        }

    }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">
        <title>登陆</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="maincss.css">
        <script type="text/javascript">
function checksubmit() {
    if (document.loginform.userid.value == "") {
        alert("用户名不能为空");
        document.loginform.userid.focus();
        return false;
    }
    if (document.loginform.password.value == "") {
        alert("密码不能为空");
        document.loginform.password.focus();
        return false;
    }

    return true;
}
</script>
    </head>
    <body>
        <%
            String s_userid = (String) session.getAttribute("userid");

            if (s_userid == null) {
        %>
        <form name="loginform" action="cust/login.jsp?op=login" method="post">
            <table width=100% cellspacing=0 cellpadding=5 border=0 class=td>
            </tr>
                <tr height=25%>
                    <td>

                        &nbsp;&nbsp;用户名
                    </td>
                    <td>
                        <input name="userid" type="text" class=formtext size=15 />
                    </td>
                </tr>
                <tr height=25%>
                    <td>
                        &nbsp;&nbsp;密码
                    </td>
                    <td>
                        <input name="password" type="password" class=formtext size=15 />
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;&nbsp;
                        <input name="loginbutton" type="submit" value="登陆"
                            onclick="return checksubmit();" />
                    </td>
                    <td>
                        <a href="cust/register.jsp">新用户注册</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                </tr>
            </table>
        </form>
        <%
            } else {
        %>
        <table class=td border=0 width=100% cellspacing=0 cellpadding=0
            bgcolor=#f6f6f6>
            <tr>
                <td><%=s_userid%>您好!
                    <br />
                    欢迎来到茶坊 官网!
                    <br />

                    <br />
                    <a href="cust/passwordedit.jsp">修改登录密码</a>
                    <br />
                    <a href="cust/userinfoedit.jsp">维护个人信息</a>
                    <br />
                    <a href="cust/myorder.jsp">查看历史订单</a>
                    <br />
                    <a href="cust/shoppingcart.jsp">查看购物车</a>
                    <br />
                    <a href="cust/leaveword.jsp">给管理员留言</a>
                    <br />
                    <a href="cust/index.jsp?op=exit">注销退出</a>
                    <br />
                </td>
            </tr>


        </table>
        <%
            }
        %>

    </body>
</html>

exception

org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause

java.lang.NullPointerException
    org.apache.jsp.cust.MyJsp_jsp._jspService(MyJsp_jsp.java:51)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
搜索更多相关主题的帖子: import java 
2016-06-14 21:09
h15188779255
Rank: 2
等 级:论坛游民
威 望:1
帖 子:17
专家分:45
注 册:2016-6-26
收藏
得分:0 
空指针异常。查看51行。“·”前面的对象可能不存在。









------别开枪
2016-06-26 12:16
快速回复:login.jsp中按下登陆 form跳转时出现500错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.063852 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved