p1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <form action="p2.jsp" method="post"> 图书价格: <input name="account" type="text"> <input type ="submit" value="提交"> </form> </body> </html>p2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% String str=request.getParameter("account"); %> <form action="p3.jsp" method="post"> 折扣: <input name="discount" type="text"><br> <input type="hidden" name="b" value="<%= str %>"> <input type="submit" value="提交"> </form> </body> </html>p3.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% String str1=request.getParameter("discount"); String str2=request.getParameter("b"); %> <%= Double.parseDouble(str2)*Double.parseDouble(str1)*0.1 %> </body> </html>