jsp -1、session对象概述(3)

电脑杂谈  发布时间:2018-01-17 17:08:33  来源:网络整理

第二步:session2.jsp

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'session.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="css/style.css">

  </head>

  <body>
  <%
    String name = request.getParameter("name");     //获取用户填写的用户名

    session.setAttribute("name",name);              //将用户名保存在session对象中
   %>
    <div align="center">
  <form id="form1" name="form1" method="post" action="sessionShow.jsp">
    <table width="28%" border="0">
      <tr>
        <td>您的名字是:</td>
        <td><%=name%></td>
      </tr>
      <tr>
        <td>您最喜欢去的地方是:</td>
        <td><label>
          <input type="text" name="address" />
        </label></td>
      </tr>
      <tr>
        <td colspan="2"><label>
          <div align="center">
            <input type="submit" name="Submit" value="提交" />
            </div>
        </label></td>
      </tr>
    </table>
  </form>
  <p>&nbsp;</p>
</div>
  </body>
</html>

第三步:sessionShow.jsp


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-60817-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 崔液
      崔液

      现在需要探讨的是对美斗争的策略

    • 沈长卿
      沈长卿

      把群里的人全部拉来了我够了吧

    • 加藤英美里
      加藤英美里

      最爱桃子

    热点图片
    拼命载入中...