此前没有做过java程序,想求一个java web程序:一个简单的登陆程序,在输入错误时能给出错误提示,并且是连接oracle数据库的.
不需要是带如structs等框架的,只要一个简单的登录系统就行.想把这个做成了再研究那些框架之类.需要有编写步骤及源码.谢谢了!
不需要是带如structs等框架的,只要一个简单的登录系统就行.想把这个做成了再研究那些框架之类.需要有编写步骤及源码.谢谢了!
<%@ 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>
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>
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>
我也是从那里入门的。现在SSH勉强会用,当然同时还得靠网上以及书本的资料。
接分 闪人
------------------------------------------
Quietly through ....