此前没有做过java程序,想求一个java web程序:一个简单的登陆程序,在输入错误时能给出错误提示,并且是连接oracle数据库的.
   不需要是带如structs等框架的,只要一个简单的登录系统就行.想把这个做成了再研究那些框架之类.需要有编写步骤及源码.谢谢了!

解决方案 »

  1.   


    <%@ page contentType="text/html; charset=gb18030" pageEncoding="gb18030"%>
    <%@ page import="User" %>
    <%
    String method = request.getParameter("method");
    if(method.equals("login")) {
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    if(username.equals("admin") && password.equals("admin")) {
    request.getRequestDispatcher().forward(reuqest, response);
    }
    }
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <body>
    <form action="login.jsp" method="post" >
    <input type="hidden" name="method" value="login">
    用户名: <input type="text" name="username"><br>
    密码: <input type="password" name="password"><br>
    <input type="submit" value="登录" />
    </form>
    </body>
    </html>
      

  2.   

    源码是不能给你的。楼上代码的步骤可以说给你表单提交给本身这个页面,这时页面会刷新,判断是否是用户登录的行为,如果是,那么从request中取出用户名和密码,根据用户名在数据库中查找该用户的记录,获得密码,比较两个密码。如果相同,说明用户信息正确,可以在session中保存用户的用户名(作为该用户在线的标志);否则,密码错误或用户名不存在,则给出用户登录失败的提示信息,让用户重新登录。
      

  3.   

    <%@ page language="java" contentType="text/html; charset=gb2312"
        pageEncoding="gb2312"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>Insert title here</title>
    <script type="text/javascript">
    function loginfunction(){
    var username=document.myform.username.value;
    var password=document.myform.password.vlaue;
    if(username.length==0 || password.length==0){
    alert("用户名或密码不能为空");
    return false;
    }
    }
    </script>
    </head>
    <body>
    <%
    String message=(String)request.getAttribute("message");
    if(message==null){
    message="";
    }else{
    out.print("<script>alert('"+message+"')</script>");
    }

     %>
     
    <form action="/lo/loginhandle.jsp" method="post" name="myform" onsubmit="return loginfunction()">
    <h3>欢迎进入登陆界面</h3>
    <table>
    <tr>
    <td>用户名</td>
    <td><input  type="text" name ="username"/></td>
    </tr>
    <tr>
    <td>密码</td>
    <td><input  type="password" name="password"/></td>
    </tr>
    <tr>
    <td><input type="submit" name="submit" value="登陆"/></td>
    <td><input type="reset" name="cansol" value="取消" /></td>
    </tr>
    </table>
    </form></body>
    </html>
      

  4.   

    <%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="gb2312" import="ImplemetDAO.*"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    int uid=0;
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    session.setAttribute("username", username);
    session.setAttribute("password", password);
    myInfo info = new myInfo();
     uid= info.QueryUid(username, password);
    session.setAttribute("uid",uid);
    session.setAttribute("uname",username);
    if(uid!=0){
    request.setAttribute("message","登录成功!"+username+",欢迎你的到来");
    request.getRequestDispatcher("/login.jsp").forward(request,response);
    }
    else{
    request.setAttribute("message","登录失败,请重新登录!");
    session.removeAttribute("uname");
    request.getRequestDispatcher("/login.jsp").forward(request,response); }
    %>
    </body>
    </html>
      

  5.   

    我的资源里面有一个JSP+SEVELET+JAVABEAN版本实现的简单注册登陆。用ACCESS做的,给点参考意见。
      

  6.   

    这个建议去MLDN DOT CN下载几个视频看下,包你很快学会。
    我也是从那里入门的。现在SSH勉强会用,当然同时还得靠网上以及书本的资料。
      

  7.   

    楼上的讲的很清除了
    接分 闪人
    ------------------------------------------
    Quietly through ....