2020-09-16

1、request

<%@ 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="request-receiver.jsp">
         姓名:<input  type="text" name="user"/><br/>
         密码:<input  type="password" name="pwd"/><br/>

          <input type="submit" name="登陆"/>
       </form>
 </body>
 </html>

2、page

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>苏日娜(page)</title>
</head>
<body>
<%!  Object object;%>
<ul>
  <li>getclass()方法的返回值:<%=page.getClass()%></>li>
  <li>hashcode()方法的返回值:<%=page.hashCode()%></>li>
  <li>tostring()方法的返回值:<%=page.toString()%></>li>
  <li>与object对象比较的返回值:<%=page.equals(object)%></>li>
  <li>与this对象比较的返回值:<%=page.equals(this)%></>li>
</ul>
</body>
</html>

3、application

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>苏日娜</title>
</head>
<body>
<body>
<%
  Object obj=application.getAttribute("counter");
  if (obj==null){
    application.setAttribute("counter",new Integer(1));
    out.println("该页面被访问了1次<br/>");
  }else {
    int countValue=new Integer(obj.toString());
    countValue++;
    out.println("该页面被访问了"+countValue+"次<br/>");
    application.setAttribute("counter",countValue);//java会自动装箱

  }
%>
</body>
</body>
</html>

4、request

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>苏日娜(requst)</title>
</head>
<body>
<form>
  <hr action="requstPage.jsp" method="post" >
  用户名: <br/>
  <input type="text" name="name"><hr/>
  男 <input type="radio" name="gender" value="男">
  女 <input type="radio" name="gender" value="女"><hr/>
  喜欢的颜色:<br/>
  紫:<input type="checkbox" name="color" value="紫">
  绿:<input type="checkbox" name="color" value="绿">
  蓝:<input type="checkbox" name="color" value="蓝"><hr/>
  来自的地区:<br/>
  <select name="country">
    <option value="内蒙古">内蒙古</option>
    <option value="吉林">吉林</option>
    <option value="黑龙江">黑龙江</option>
  </select></hr>
  <input type="submit" value="提交">
  <input type="reset" value="重置">
</form>
</body>
</html>
</body>
</html>

5、exception

<%@ page contentType="textml;charset=UTF-8" language="java" errorPage="error.jsp" %>
<html>
    <head>
        <title>exception</title>
    </head>
    <body>
        <%
            int a=8;
            int b=0;
            int c=a/b;
        %>
    </body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java"
         pageEncoding="UTF-8" isErrorPage="true"%>
<html>
<head>
    <title>exception对象</title>
</head>
<body>
<hr>
异常类型:<%=exception.getClass()%><br/><br/>
异常信息:<%=exception.getMessage()%>
<hr/>
</body>
</html>

6、config

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>config</title>
</head>

<body>
<%
    String url = config.getInitParameter("url");
    String str = config.toString();
    out.print("page对象的initParameter方法:"+url+"</br>");
    out.print("page对象的toString方法:"+str);
%>
</body>
</html>

7、session

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <base href="<%=basePath%>">

    <title>session1</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="css/style.css">

</head>

<body>
<form id="form1" name="form1" method="post" action="session2.jsp">
    <div align="center">
        <table width="40%" border="0">
            <tr>
                <td width="36%"><div align="center">您的名字是:</div></td>
                <td width="64%">
                    <label>
                        <div align="center">
                            <input type="text" name="name" />
                        </div>
                    </label>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <label>
                        <div align="center">
                            <input type="submit" name="Submit" value="提交" />
                        </div>
                    </label>
                </td>
            </tr>
        </table>
    </div>
</form>
</body>
</html>

8、response

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>201819101010 苏日娜</title>
</head>
<body>
<meta http-equiv="Content-Type" content="text/html;charst=utf-8">
<title>response</title>
</head>
<body>
<center>
  跳转页面到百度主页
  <%//response.sendRedirect("https://www.baidu.com");%>
</center>
</body>
</body>
</html>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值