
用Myeclipse制作一个jsp项目,求代码?????
用Myeclipse制作一个jsp项目,包括有一个welcome页,在该页上设置一个登录界面让用户输入用户名和密码,可以转到其它页,在目的页显示出用户输入的用户名和密码...
用Myeclipse制作一个jsp项目,包括有一个welcome页,在该页上设置一个登录界面让用户输入用户名和密码,可以转到其它页,在目的页显示出用户输入的用户名和密码
展开
展开全部
当时上学时候做的,用到了session,因为意思差不多,所以懒得再去写了,直接拿来用。希望能采纳。
登录页 login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'login.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">
-->
</head>
<body>
<form method="post" action="proc.jsp">
用户名:<input type="text" name="username" /><br/>
口 令:<input type="password" name="pass"/><br/>
<input type="submit" value="提交" />
</form>
</body>
</html>
判断页面 proc.jsp:
<%@ page language="java" import="java.util.*,javax.swing.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'proc.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">
-->
</head>
<body>
<%
String name=request.getParameter("username");
String pass=request.getParameter("pass");
if(name.equals("admin")&&pass.equals("88888")) {
session.setAttribute("user",name);
%>
<jsp:forward page="Main.jsp"/>
<%
}
else
{
JOptionPane.showMessageDialog(null,"错误的用户名或口令!");
%>
<jsp:forward page="err.jsp"></jsp:forward>
<%
}%>
<br>
</body>
</html>
欢迎页面 Main.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'Main.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">
-->
</head>
<body>
<%
String user=(String)session.getAttribute("user");
if(user!=null){
%>
你已经进入主页面,<%=user %>欢迎光临!<br>
<%
}
else
{
response.sendRedirect("login.jsp");
}
%>
</body>
</html>
登录页 login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'login.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">
-->
</head>
<body>
<form method="post" action="proc.jsp">
用户名:<input type="text" name="username" /><br/>
口 令:<input type="password" name="pass"/><br/>
<input type="submit" value="提交" />
</form>
</body>
</html>
判断页面 proc.jsp:
<%@ page language="java" import="java.util.*,javax.swing.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'proc.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">
-->
</head>
<body>
<%
String name=request.getParameter("username");
String pass=request.getParameter("pass");
if(name.equals("admin")&&pass.equals("88888")) {
session.setAttribute("user",name);
%>
<jsp:forward page="Main.jsp"/>
<%
}
else
{
JOptionPane.showMessageDialog(null,"错误的用户名或口令!");
%>
<jsp:forward page="err.jsp"></jsp:forward>
<%
}%>
<br>
</body>
</html>
欢迎页面 Main.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'Main.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">
-->
</head>
<body>
<%
String user=(String)session.getAttribute("user");
if(user!=null){
%>
你已经进入主页面,<%=user %>欢迎光临!<br>
<%
}
else
{
response.sendRedirect("login.jsp");
}
%>
</body>
</html>
展开全部
刚好又一个现成的
这是welcome页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>题1和2</title>
</head>
<body>
<center>
<form action="help.jsp" method="post">
<table>
<tr>
<td>
用户名:
</td>
<td>
<input type="text" name="user" />
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<input type="password" name="password" />
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="提交" />
<input type="reset" value="重置" />
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
这是显示页面 改成help.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<meta http-equiv="refresh" content="5" ; url="ques12.jsp">
<p align="center">
用户名:<%=request.getParameter("user")%>
<br />
密 码:<%=request.getParameter("password")%>
</p>
<center>
<%!int number = 1;%>
<%
number ++;
%>
<%="如果你看见括号内的数字在增加表示页面刷新成功了("+number+")成功了!!!"%>
<font color="#FF0000">页面刷新频率为5s/次</font>
</center>
这是welcome页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>题1和2</title>
</head>
<body>
<center>
<form action="help.jsp" method="post">
<table>
<tr>
<td>
用户名:
</td>
<td>
<input type="text" name="user" />
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<input type="password" name="password" />
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="提交" />
<input type="reset" value="重置" />
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
这是显示页面 改成help.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<meta http-equiv="refresh" content="5" ; url="ques12.jsp">
<p align="center">
用户名:<%=request.getParameter("user")%>
<br />
密 码:<%=request.getParameter("password")%>
</p>
<center>
<%!int number = 1;%>
<%
number ++;
%>
<%="如果你看见括号内的数字在增加表示页面刷新成功了("+number+")成功了!!!"%>
<font color="#FF0000">页面刷新频率为5s/次</font>
</center>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这种东西你自己做不出来???太简单了吧。
追问
不会的...你能帮做一份吗??我的邮箱515645020@qq.com........谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-05
展开全部
百度
myeclipse jsp 登录 例子
myeclipse jsp 登录 例子
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询