| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1624 人关注过本帖
标题:关于jsp的问题
只看楼主 加入收藏
热学男儿
Rank: 1
等 级:新手上路
帖 子:109
专家分:0
注 册:2007-4-28
收藏
 问题点数:0 回复次数:3 
关于jsp的问题
刚刚学习jsp,个人写了一个jsp登录页面,并写了一个java类,用于验证用户名和密码,还没有连接数据库,只是有测试数据,问题是,在我没有写java类时,单独运行jsp登录页面能够正常运行,当写了java类后,就不正常了,小弟翻了半天书也没有找到原因,望各位帮忙。
我写的jsp登录页面的代码是
<%@ page language="java" import="login.*;" pageEncoding="gb2312"%>
<%@ page errorPage="/error.jsp"%>
<%@ page contentType="text/html;"%>
<jsp:useBean id="s_psBean" class="login.loginPass" scope="session">
<%
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 'index.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">
    <link href="indexCss.css" type="text/css" rel="Stylesheet" >
    -->
  </head>
  <body bgcolor="ffffc0">
    <center>
      <div id="divall" style="width:720px;height:570px">
        <div style="width:65%;height:35px;float:left"></div>
        <div style="width:35%;height:25px;float:left"></div>
        <div style="width:35%;float:left;text-align:center">
          <table>
            <tr>
              <td><img src="images/post.gif"></td>
              <td width="5px"></td>
              <td><a style="text-decoration:none; color:black" href="mailto:yidezhi@联系我们</a></td>
            </tr>
          </table>
        </div>
        <div style="float:left;width:4%;height:20px"></div>
        <div id="divtitle" style="text-align:left;float:left;width:61%;filter:shadow(color:green strength=5 direction=135)">
          <a style="font-size:40px;font-family:楷体;font-weight:bolder">计算机网上报价系统</a>
        </div>
        <div style="float:left;width:35%;height:15px"></div>
        <div id="divmarquee" style="text-align:center;float:left;width:35%;height:100px">
          <table style="width:200px;height:100px">
            <tr>
              <td>
                <marquee direction="up" scrollamount="3" style="height:100px;width:200px">
                  <font size="2">啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊</font>
                </marquee>
              </td>
            </tr>
          </table>
        </div>
        <div id="divimg" style="text-align:center;float:left;width:100%;height:200px">
          <img src="images/image.gif" style="width:100%">
        </div>
        <div style="float:left;width:65%;height:20px"></div>
        <div id="divlogin" style="text-align:center;float:left;width:50%;height:150px">
        <form id="form1" method="post" action="index.jsp">
          <table>
            <tr>
              <td>用户名:</td>
              <td colspan="2"><input type="text" name="username" style="height:20px;width:120px" value=""></td>
              <td rowspan="6"><img src="images/Login.gif"></td>
            </tr>
            <tr height="5px">
              <td height="5px"></td>
              <td colspan="2" height="5px"></td>
            </tr>
            <tr>
              <td>密  码:</td>
              <td colspan="2"><input type="Password" name="password" style="height:20px;width:120px" value=""></td>
            </tr>
            <tr>
              <td height="5px"></td>
              <td colspan="2" height="5px"></td>
            </tr>
              <tr>
                <td align="center">
                  <input type="radio" name="radio" id="radiomanenger">
                    <span class="red">管理员</span>
                </td>
                <td colspan="2" align="center">
                  <input type="radio" name="radio" id="radioapi">
                    <span class="red">注册会员</span>
                </td>
              </tr>
              <tr>
                <td height="5px"></td>
                <td colspan="2" height="5px"></td>
              </tr>
              <tr>
                <td align="center">
                <input type="hidden" name="operation" value="login">
                <input type="submit" name="login" value="登   录">
                </td>
                <td align="center"><input type="reset" id="reset" value="重 设"></td>
                <td align="center"><input type="submit" id="zhuce" value="注 册"></td>
                <td align="center"><input type="submit" id="nonamelogin" value="匿名登录"></td>
              </tr>
          </table>
        </form>
        </div>
        <%
        String operation=request.getParameter("operation"); //得到本页登录的操作动作
        if(operation==null){operation="";} //防止因为operation=null时的错误
        if(operation.equals("login")) //如果是登录操作
        {
           String Username=request.getParameter("username"); //用户名
           String Password=request.getParameter("password"); //密码
           s_psBean.setPass(Username,Password); //利用javaBean进行权限验证
           if(s_psBean.getPass()==1) //如果密码正确则将页面引导到系统操作页面
           {
           %>
           <jsp:forward page="login.jsp"></jsp:forward>
           <%
           }
           if(s_psBean.getPass()==2) //密码错误
           {
              out.println("<font color=red>对不起!您输入的密码错误,请重新输入用户名与密码!</font>");
              out.close();
           }
           if(s_psBean.getPass()==0)  //用户名不存在
           {
              out.println("<font color=red>对不起!您输入的用户名不存在,请重新输入用户名和密码!</font>");
              out.close();
           }
        }
         %>
        <div style="float:left;width:15%;height:150px"></div>
        <div id="divnote" style="float:left;width:35%;height:150px">
          <table>
            <tr>
                <td width="30px" align="left"><img src="images/hangbiao.gif" /></td>
                <td>电脑硬件报价</td>
              </tr>
              <tr>
                <td width="30px" align="left"><img src="images/hangbiao.gif" /></td>
                <td>装机配置建议</td>
              </tr>
              <tr>
                <td width="30px" align="left"><img src="images/hangbiao.gif" /></td>
                <td>各种配置推荐</td>
              </tr>
              <tr>
                <td width="30px" align="left"><img src="images/hangbiao.gif" /></td>
                <td>客户配置查询</td>
              </tr>
              <tr>
                <td width="30px" align="left"><img src="images/hangbiao.gif" /></td>
                <td>用户密码修改</td>
              </tr>
          </table>
        </div>
        <div style="text-align:center;float:left;width:100%">
          <h5>河北工业大学计算机网上报价系统开发小组 版权所有 盗版不究</h5>
        </div>
      </div>
    </center>
  </body>
</html>
下面是我写的java类的代码
package login;

import java.util.*;

public class loginPass
{
    String lusername=""; //用户名
    String lpassword=""; //密码
    int auth=0;  //用于判断是否密码错误或用户名是否存在
    public void setPass(String susername, String spassword)
    {
        if(susername=="yidezhi")
        {
            if(spassword=="000000")
            {
                lusername=susername;
                lpassword=spassword;
                auth=1; //用户名存在且密码正确
            }
            else{auth=2;} //用户名存在但密码错误
        }
        else{auth=0;} //用户名不存在
    }
    public int getPass() //通过密码验证
    {
        return(auth);
    }
    public String getUsername() //返回用户名
    {
        return(lusername);
    }
    public String getPassword() //返回密码
    {
        return(lpassword);
    }
    public void loginOut() //退出系统时的数据处理
    {
        lusername=null;
        lpassword=null;
        auth=0;
    }
}
请各位帮忙看看是不是什么地方的调用不对呢
提前感谢

[[it] 本帖最后由 热学男儿 于 2008-4-8 13:08 编辑 [/it]]
搜索更多相关主题的帖子: jsp quot 数据库 java page 
2008-04-08 11:27
Gramary
Rank: 4
等 级:贵宾
威 望:13
帖 子:769
专家分:0
注 册:2007-7-9
收藏
得分:0 
你要把你的错误贴处来看看

学编程不能急,要慢慢来。
2008-04-08 12:52
热学男儿
Rank: 1
等 级:新手上路
帖 子:109
专家分:0
注 册:2007-4-28
收藏
得分:0 
主页面也运行不出来,下面是主页面上显示的信息
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: /index.jsp(163,0) Unterminated &lt;jsp:useBean tag
    org.apache.(DefaultErrorHandler.java:40)
    org.apache.(ErrorDispatcher.java:407)
    org.apache.(ErrorDispatcher.java:132)
    org.apache.(Parser.java:1670)
    org.apache.(Parser.java:1004)
    org.apache.(Parser.java:960)
    org.apache.(Parser.java:1138)
    org.apache.(Parser.java:1448)
    org.apache.(Parser.java:133)
    org.apache.(ParserController.java:216)
    org.apache.(ParserController.java:103)
    org.apache.(Compiler.java:167)
    org.apache.(Compiler.java:306)
    org.apache.(Compiler.java:286)
    org.apache.(Compiler.java:273)
    org.apache.jasper.(JspCompilationContext.java:566)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    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)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.13

下面是服务器信息里面显示的
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /index.jsp(163,0) Unterminated &lt;jsp:useBean tag
    at org.apache.(DefaultErrorHandler.java:40)
    at org.apache.(ErrorDispatcher.java:407)
    at org.apache.(ErrorDispatcher.java:132)
    at org.apache.(Parser.java:1670)
    at org.apache.(Parser.java:1004)
    at org.apache.(Parser.java:960)
    at org.apache.(Parser.java:1138)
    at org.apache.(Parser.java:1448)
    at org.apache.(Parser.java:133)
    at org.apache.(ParserController.java:216)
    at org.apache.(ParserController.java:103)
    at org.apache.(Compiler.java:167)
    at org.apache.(Compiler.java:306)
    at org.apache.(Compiler.java:286)
    at org.apache.(Compiler.java:273)
    at org.apache.jasper.(JspCompilationContext.java:566)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
    at org.apache.tomcat.(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
2008-04-08 13:10
hwoarangzk
Rank: 4
来 自:冰封王座
等 级:贵宾
威 望:12
帖 子:1894
专家分:0
注 册:2007-7-17
收藏
得分:0 
org.apache.jasper.JasperException: /index.jsp(163,0) Unterminated &lt;jsp:useBean tag
<jsp:useBean id="s_psBean" class="login.loginPass" scope="session" />
少个"/"

I'm here, as always...
2008-04-08 13:55
快速回复:关于jsp的问题
数据加载中...
 
   



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

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