怎么编写一个JSP的页面,能实现在表单中输入用户名和密码并按下提交按扭后,在另一页面显示提交信息?

如题所述

A页是静态页
<html>
<head>
<title>发表</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

</head>

<body>
<form action="affirm.jsp" method="post">
标题:<input type="text" name="title" /><br/>
内容:<textarea rows="5" cols="20" name="content"></textarea><br/>
<input type="submit" value="提 交" />
</form>
</body>
</html>

B页JSP跳转页
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String title = request.getParameter("title");
String content = request.getParameter("content");
%>

<html>
<head>
<base href="<%=basePath%>">

<title>确认</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">

</head>

<body>
<table>
<tr>
<td>标题:</td><td><%=title %></td>
</tr>
<tr>
<td>内容:</td><td><%=content %></td>
</tr>
</table>

<input type="text" value="<%=title %>"/><br/>
<textarea rows="5" cols="20"><%=content %></textarea>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考
相似回答