js页面传值

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>a</title>
  <script type="text/javascript">
  function test2(){
     document.getElementById("list").value=<%=session.getAttribute("select")%>;
  }
  </script>
</head>
<body onload="test2()">
  <form action="b.jsp" method="post">
   <select name="list" id="list" >
    <option value=null selected="selected">--select--</option>
    <option value="1">name</option>
    <option value="2">age</option>
    <option value="3">sex</option>
   </select>
   <input type="submit" value="提交" />
  </form>
</body>
<%session.removeAttribute("select"); %>
</html>
_____________________________________________
b.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>b</title>
</head>
<body>
<%session.setAttribute("select",request.getParameter("list"));%>
<input type="button" onclick="window.open('a.jsp')" value="转回a"/>
</body>
</html>

你可能感兴趣的:(java,html,jsp)