Java web开发技术 第二章

2

<%@ 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>登录</title>
</head>
<body>
            <h3>管理员登录</h3>
            <form action="yanzheng.jsp" method="post" name="myform">
            登录名:<input name="user" type="text"><br/><br/>
            密&nbsp;&nbsp;&nbsp;&nbsp;码:<input name="pwd" type="password"><br/><br/>
            <input type="submit" value="登录">
            </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>登录处理页面</title>
</head>
<body>
       <%
           request.setCharacterEncoding("UTF-8");
           String name=request.getParameter("user");
       String passWord=request.getParameter("pwd");
        if(name.equals("admin")&&passWord.equals("123")){
        request.getRequestDispatcher("adminInfo.jsp").forward(request, response);
        }else{
        	response.sendRedirect("err.jsp");
        }
       %>
</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>管理员信息</title>
</head>
<body>
<h3>管理员信息</h3>
<table border="1px" width="250px" cellpadding="10px">
<tr>
 <td>姓名</td><td>阿猫</td>
 </tr>
 <tr>
 <td>性别</td><td>男</td>
 </tr>
 <tr>
 <td>身高</td><td>226cm</td>
 </tr>
 <tr>
 <td>身份</td><td>管理员</td>
 </tr>
 <tr>
 <td>兴趣爱好</td><td>编程,删帖</td>
 </tr>
</table>
</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>管理员信息</title>
</head>
<body>
用户名或密码错误
</body>
</html>

3.

<%@ 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>选择交通工具</title>
</head>
<body>
<form action="info.jsp"  method="post">
 请选择您要出行的交通工具
 自行车:<input type="checkbox" value="自行车" name="chooise">
 摩托车:<input type="checkbox" value="摩托车" name="chooise">
电瓶车:<input type="checkbox" value="电瓶车" name="chooise">
 小轿车:<input type="checkbox" value="小轿车" name="chooise"><br><br>
 <input type="submit" value="提交">
 </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>选择的所有交通工具</title>
</head>
<body>
            <%   
            request.setCharacterEncoding("UTF-8");
           String[] chooises=request.getParameterValues("chooise");
              for(String chooise:chooises){
            	  out.print(chooise+" ");
              }
            %>
            
</body>
</html>

 

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>
           <IMG src="../images/head.gif">
          
</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>
        
        <%@include file="head.jsp" %><br>
        <div style="font-size:30px;color:red;position:relative;left:40px"><%
        out.print("你好,欢迎来到Java Web的世界!");
        %></div>
        
       
           
</body>
</html>

5.

<%@ 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>生成随机数字</title>
</head>
<body>
          <%
               int num  =(int)(Math.random()*9);
          session.setAttribute("luck", num);
          session.setMaxInactiveInterval(10*60);
          request.getRequestDispatcher("showLuckNum.jsp").forward(request, response);
          %>
       
        
</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>显示幸运数字</title>
</head>
<body>
    <%     
                request.setCharacterEncoding("UTF-8");
             int luck  =(int)session.getAttribute("luck");
              out.print("幸运数字为:"+luck);
      %>
</body>
</html>

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值