app.jsp

来自「结合Apache和Tomcat实现集群和负载均衡」· JSP 代码 · 共 35 行

JSP
35
字号
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.util.Enumeration"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>集群Tomcat的session复制测试(Tomcat2)</title>
</head>

<body bgcolor="#FF0000">    
服务器信息:<% out.println(request.getServerName() + " : " + request.getServerPort()+"<br/>");%>      
<%       
  out.println("<br/>Session ID:" + session.getId()+"<br/>");  //如果有新的 Session 属性设置       
  String dataName = request.getParameter("dataName");       
  if (dataName != null && dataName.length() > 0) {       
     String dataValue = request.getParameter("dataValue");       
     session.setAttribute(dataName, dataValue);       
  }       
  out.print("<b>Session 列表</b><br/>");         
  Enumeration e = session.getAttributeNames();       
  while (e.hasMoreElements()) {       
     String name = (String)e.nextElement();       
     String value = session.getAttribute(name).toString();       
     out.println( name + " = " + value+"<br/>");    
   }       
%>      
  <form action="app.jsp" method="POST">      
    名称:<input type=text size=20 name="dataName">      
     <br/>      
    数值:<input type=text size=20 name="dataValue">      
     <br/>      
    <input type="submit">      
   </form> 
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?