编写如下三个文件:a.htm显示一个文本框和一个提交按钮;b.jsp将a.jsp表单传递的信息存入session变量flag中
1个回答
展开全部
a.html
<html><head><title></title></head><body>
<form action="b.jsp" >
<input type=text name="123">
<input type="submit" value="提交">
</form>
</body></html>
b.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html><head><title></title></head><body>
<% String 1234=request.getParameter("123");
session.setAttribute("flag",1234);%>
</body></html>
c.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html><head><title></title></head><body>
<% request.setCharacterEncoding("UTF-8")%>
<%=(String)session.getAttribute("flag")%>
</body></html>
<html><head><title></title></head><body>
<form action="b.jsp" >
<input type=text name="123">
<input type="submit" value="提交">
</form>
</body></html>
b.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html><head><title></title></head><body>
<% String 1234=request.getParameter("123");
session.setAttribute("flag",1234);%>
</body></html>
c.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html><head><title></title></head><body>
<% request.setCharacterEncoding("UTF-8")%>
<%=(String)session.getAttribute("flag")%>
</body></html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询