首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 菜鸟问题多啊! 验证管理员名称和密码 出错
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • zhoulehui
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    • 结帖率:
    发表于:2008-08-19 23:54:00 楼主
    //server2000 jsp tomcat 连接数据库可以成功
    1.jsp
    <%@page contentType="text/html;charset=gb2312"%>
    <html>
    <head> <title>管理系统! </title>
    </head>
    <body> <center> <h4> <font color="red" >请先登入 </font> </h4> </center>
    <form name="form1" action="2.jsp" method="post">
    <center>
    <p>用户: <input type="text" name="userId" > </p>
    <p>密码: <input type="password" name="userPwd"> </p>
    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
    </center>
    </form>
    </body>
    </html>
    2.jsp
    <%@ page contentType="text/html;charset=gb2312"%>
    <%@ page import="java.sql.*,java.io.*"%>
    <%! String username,password,adminvalue,pwdvalue;%>

    <%request.setCharacterEncoding("gb2312");
    response.setContentType("text/html;charset=gb2312");//这里报错
    %>

    <%
    username=request.getParameter("name");
    password=request.getParameter("password");
    adminvalue="sa";
    pwdvalue="123456";
    if(username==null)
    {
    response.sendRedirect("err.jsp");
    }
    if(password.equals(""))
    {
    response.sendRedirect("err.jsp");
    }
    if(adminvalue.equals(username)&& pwdvalue.equals(password))
    {
    Cookie theadminok=new Cookie("adminok","true");
    response.addCookie("theadminok");//这里出错  是什么原因啊
    response.sendRedirect("manager.jsp");

    }
    else{
    response.sendRedirect("err.jsp");

    }
    %>


    出错信息
    2008-8-19 23:50:20 org.apache.catalina.core.StandardWrapperValve invoke
    严重: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSP:

    An error occurred at line: 25 in the jsp file: /test/chklogin.jsp
    The method addCookie(Cookie) in the type HttpServletResponse is not applicable for the arguments (String)
    22: if(adminvalue.equals(username)&& pwdvalue.equals(password))
    23: {
    24: Cookie theadminok=new Cookie("adminok","true");
    25: response.addCookie("theadminok");
    26: response.sendRedirect("manager.jsp");
    27:
    28: }

    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • andywiliang
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-09-20 12:17:431楼 得分:0
    帮顶............

    -------------------------------------------------------
    万部在线免费电影
    http://176969.cn



    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • andywiliang
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-09-20 12:18:272楼 得分:0
    该回复于2008-09-27 12:19:17被版主删除
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • PRINCE_LF
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-09-22 12:34:063楼 得分:0
    <%%>这不是asp代码吗
    不知道是不是我见识少
    if(username==null)
    {
    response.sendRedirect("err.jsp");
    }
    这应该是javascript
    JSP网页能够混在一起用吗
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved