发给你吧:
登录页面:
<html>
<head>
<title>用户登录</title>
<%@ page contentType="text/html;charset=gb2312"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<script>
<!--
function sf()
{
document.form1.user.focus();
}
// -->
</script>
<body bgcolor="#FFFFFF" text="#000000" background="images/background1.jpg" onLoad=sf()>
<div align="center">
<p>
<br><br>
<b><font color="#FF0000" size="3">用户登陆</font></b></p>
</div>
<form name="form1" method="post" action="login.jsp">
<div align="center">用户名:
<input type="text" name="user" maxlength="50" size="15">
<br>
密码:
<input type="password" name="pass" maxlength="50" size="15">
<br><br>
<input type="submit" name="Submit" value="登录" onclick="sub()">
<input type="reset" name="Submit2" value="取消">
</div>
<script language="javascript">
function sub()
{
if(document.form1.user.value=="")
{
window.alert("请输入你的用户名!");
window.form1.user.focus();
return false;
}
if(document.form1.pass.value=="")
{
window.alert("请输入你的密码!");
window.form1.pass.focus();
return false;
}
document.form1.submit();
}
</script></form>
</body>
</html>登录处理页面(login.jsp):<jsp:useBean id="change" scope="page" class="CharacterChange.CharacterChange" />
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java" import="java.sql.*"%>
<%
//读取表单输入的账号密码
String user_name=change.getStr1(request.getParameter("user").trim());
String pass_word=change.getStr1(request.getParameter("pass").trim());
Connection conn=null;//数据库连接对象 
Statement stmt=null; //SQL语句对象 
String strCon=null; //数据库连接字符串 
//连接数据库
String url="jdbc:odbc:db";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection(url);
//创建一个可以滚动的只读的SQL语句对象 
stmt=conn.createStatement(); 
//从数据库读取账号密码
String sql="select * from admin where user='"+user_name+"' and pass='"+pass_word+"'";
ResultSet rs=stmt.executeQuery(sql);
%>
<%
//判断用户是否存在
if(!rs.next())
{
out.print("没有这个用户!");
%>
<a href="index.jsp">返回</a>
<%
}
else 
{
        //设置user的Session
session.setAttribute("user",user_name);
session.setAttribute("user_login","yes");
response.sendRedirect("main.jsp");
}
%>

解决方案 »

  1.   

    提交页面(login.jsp):
    <%@ page contentType="text/html; charset=GB2312"%>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>中国</title>
    </head>
    <body>
    <p align="center"><font size="6" color="#0000FF">中     国</font></p>
    <p align="center"><font size="5" color="#0000FF">客户系统</font></p>
    <p align="center"><font color="#0000FF" size="4">(Version1.0)</font></p>
    <p align="center"> </p>
    <form method="get" action="denglu.jsp">
        <p align="center"><input type="button" value="用户名:" name="txtname"><input type="text" name="T1" size="20"></p>
      <p align="center"><input type="button" value="密  码:" name="txtpassword"><input type="password" name="T2" size="20"></p>
      <p align="center"><input type="submit" value="登  陆" name="B1"><input type="reset" value="全部重写" name="B2"></p>
    </form><p align="center"> </p>
    <p align="center"> </p>
    <p align="center"> </p>
    <p align="center">中国版权所有 </p>
    <p align="center">copyright @ for IC All rights reserved</p>
    <p align="center">2003/2/26</p></body></html> 处理页面(denglu.jsp):
    <%@ page contentType="text/html; charset=GB2312"%>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>用户管理</title>
    </head>
    <body>
    <div aling="center">
    <p><font size="5"><b><font color="#000000">用户窗口</font></b></font></p><%
    int n;
    String temp1=new String();
    String temp2=new String();
    temp1=request.getParameter("txtname");
    temp2=request.getParameter("txtpassword");
    n=temp1.length()*temp2.length();
    if (n==0){
    %>
    <p>您的输入有误,请重新输入!</p>
    <p><a href="login.jsp">返回</a></p>
    <%
    }
    else {
    String tempuser=new String();
    String tempid=new String();
    int tempupnum;
    String url=new String();
    url="jdbc:odbc:denglu";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection(url);
    Statement stmt=con.createStatement();
    String Sql=new String();
    SQL="SELECT * FROM user WHERE user=""+temp1+""and password=""+temp2+"";
    ResultSet rs=stmt.executeQuery(SQL);
    if (rs.next()){
    tempuser=rs.getString("user");
    tempid=rs.getString("password");
    tempupnum=rs.getint("upnum")+1;
    rs.close();
    SQL="UPDATE user SET upnum="+ Integer.toString(tempupnum)+"WHERE user=""+temp1+"";
    %>
    <%
    int i=stmt.executeUpdate(SQL);
        session.putValue("user",tempuser);
    %>
    <p><b>用户<%=tempuser%>(<%=tempid%>),您好!</b></p>
    <p><b>您上站已经<%=tempupnum%>次。</b></p>
    <p><b>本窗口提供客户交易分析服务</b></p>
    <p><a href="index1.jsp">查询明细</a></p>
    <p><a href="index2.jsp">分析交易</a></p>
    <%
    }
    else{
    %>
    <p>这个用户不存在,请重新登陆。</p>
    <p><a href="login.jsp">返回</a></p>
    <%
    }
    stmt.close();
    con.close();
    }
    %>
    </div>
    </body>
    </html>
    请帮忙分析一下这个怎么不行!
    数据库用SQL已经做了数据源(datasource\denglu)
    denglu表中有user,password,upnum三个字段
      

  2.   

    login.jsp:<%@ page contentType="text/html; charset=GB2312"%>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>中国工商银行广东省分行营业部</title>
    </head>
    <body>
    <p align="center"><font size="6" color="#0000FF">中国工商银行广东省分行营业部</font></p>
    <p align="center"><font size="5" color="#0000FF">客户交易查询分析系统</font></p>
    <p align="center"><font color="#0000FF" size="4">(Version1.0)</font></p>
    <p align="center"> </p>
    <form method="get" action="denglu.jsp">
        <p align="center"><input type="button" value="用户名:" name="txtname"><input type="text" name="T1" size="20"></p>
      <p align="center"><input type="button" value="密  码:" name="txtpassword"><input type="password" name="T2" size="20"></p>
      <p align="center"><input type="submit" value="登  陆" name="B1"><input type="reset" value="全部重写" name="B2"></p>
    </form><p align="center"> </p>
    <p align="center"> </p>
    <p align="center"> </p>
    <p align="center">中国工商银行 版权所有 </p>
    <p align="center">copyright @ for ICBC All rights reserved</p>
    <p align="center">2003/2/26</p></body></html> 登陆页面(denglu.jsp):
    <%@ page contentType="text/html; charset=GB2312"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="java.lang.*"%>
    <%@ page import="java.awt.*"%>
    <%@ page import="java.util.*"%><html>
    <head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>用户管理</title>
    </head>
    <body>
    <div aling="center">
    <p><font size="5"><b><font color="#000000">用户窗口</font></b></font></p><%
    int n;
    String temp1=new String();
    String temp2=new String();
    temp1=request.getParameter("txtname");
    temp2=request.getParameter("txtpassword");
    n=temp1.length()*temp2.length();
    if (n==0){
    %>
    <p>您的输入有误,请重新输入!</p>
    <p><a href="login.jsp">返回</a></p>
    <%
    }
    else {
    String tempuser=new String();
    String tempid=new String();
    int tempupnum;
    String url=new String();
    url="jdbc:odbc:denglu";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection(url);
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("SELECT * FROM user WHERE user='"+temp1+"'and password='"+temp2+"'");
    if (rs.next()){
    tempuser=rs.getString("user");
    tempid=rs.getString("password");
    tempupnum=rs.getint("upnum")+1;
    rs.close();

    %>
    <%
    int i=stmt.executeUpdate("UPDATE user SET upnum="+ Integer.toString(tempupnum)+"WHERE user='"+temp1+"'");
        session.putValue("user",tempuser);
    %>
    <p><b>用户<%=tempuser%>(<%=tempid%>),您好!</b></p>
    <p><b>您上站已经<%=tempupnum%>次。</b></p>
    <p><b>本窗口提供客户交易分析服务</b></p>
    <p><a href="index1.jsp">查询明细</a></p>
    <p><a href="index2.jsp">分析交易</a></p>
    <%
    }
    else{
    %>
    <p>这个用户不存在,请重新登陆。</p>
    <p><a href="login.jsp">返回</a></p>
    <%
    }
    stmt.close();
    con.close();
    }
    %>
    </div>
    </body>
    </html> 
      

  3.   

    to sgdb(三个代表) (::
    错误信息代码:type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 29 in the jsp file: /denglu.jspGenerated servlet error:
        [javac] Compiling 1 source fileC:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\denglu_jsp.java:100: cannot resolve symbol
    symbol  : method getint  (java.lang.String)
    location: interface java.sql.ResultSet
    tempupnum=rs.getint("upnum")+1;
                                ^An error occurred at line: 29 in the jsp file: /denglu.jspGenerated servlet error:
    Note: C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\denglu_jsp.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    1 error
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:340)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
    at java.lang.Thread.run(Thread.java:536)
    29行为: <p><a href="login.jsp">返回</a></p>请大家帮忙看一下!
      

  4.   

    数据库中已经做数据源(名称为denglu)
    表名为user
    user中有字段:user(text)password(text) upnum(int)
      

  5.   

    csdnluhao (陆皓) :现在没时间做啊,谁有的就贴给我啦,我是刚入门的,
    为什么没有时间做。不会是应聘的题吧?!如果是,那我们就更加不能告诉你听了,因为以你这个水平去应聘,如果上了,那也是一时的,以后你还是不会很多东西,而且会让别的程序员(非jsp程序员)还以为我们做jsp的人都是这样的。损名声,我觉得还是你要多用用心去学,这样的水平还是先不要找工作。会成功的。