第三次作业

1、如果用户输入正确的账号密码,则提示问候语句;如果用户输入错误的账号密码,则提示账号密码有误。

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
     String str=request.getParameter("username");
     String pwd=request.getParameter("pwd");
     if(null!=str){
    	 if(str.equals("tom")&&pwd.equals("123")){
    		 out.println("您好,tom!");
    	 }else{
    		 out.println("您输入的账号密码有误,请重新输入!");
    	 }
     }
%>      
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form action="index.jsp" method="post">
                  账号:<input type="text" name="username"/> <br>
                  密码:<input type="password" name="pwd"/> <br>   
     <input type="submit" value="登录"/>                     
    </form>         
</body>
</html>

 

2、任意编写3-4个页面,为每个页面添加权限控制。如果用户已经登录,则在每个页面页首提示:欢迎你,**。如果没有登录跳转到这个页面,则提示:非法访问。 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
	登录
	<form action="index3.0.jsp" method="post">
		<ul style="list-style:none">
		    <li>登录名:<input name="name" type="text" /></li>
			<li>邮箱    :<input name="number" type="text" /></li>
			<li><input type="submit" value="登录" /></li>
		</ul>
	</form>
</body>
</html>


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		String number1=request.getParameter("number");
		session.setAttribute("snumber",number1);
		String name1=request.getParameter("name");
		session.setAttribute("sname",name1);
	%>
	<%
		String number=(String)session.getAttribute("snumber");	
		String name=(String)session.getAttribute("sname");
		if(name.equals("")&&number.equals("")){
			out.println("非法访问"+"<br>");D
		}
		else{
			out.println("欢迎你"+name+"<br>");
		}
	%>
	<a href="index4.0.jsp">跳转</a>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		String e-mail=(String)session.getAttribute("se-mail");
		String name=(String)session.getAttribute("sname");
	%>
	您的session邮箱为:<%=e-mail %><br>
	您的session姓名为:<%=name %>
</body>
</html>

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值