java相关web-JSP请求与响应编程

先上图

 

 

 

要求:按下提交按钮,跳出内容页面

原网页regist.jsp 代码:

<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>Insert title here</title>
</head>
<body>
<form name="form1" id="form1" method="post" action="doregist.jsp">
<p>用户名:
    <input type="text" name="yhm" id="yhm">    
</p>
    <p>密码:
    <input type="password" name="mm" id="mm">    
</p>
<p>年龄:
    <input type="text" name="nl" id="nl">    
</p>

<p>性别:
  <label>
    <input type="radio" name="xb" value="男" id="xb_0">
    男</label>

  <label>
    <input name="xb" type="radio" id="xb_1" value="女" checked="checked">
    女</label>
  </p>

<p>特长:
<input type="checkbox" name="tc" id="tc" value="唱">唱
<input type="checkbox" name="tc" id="tc" value="跳">跳
<input type="checkbox" name="tc" id="tc" value="足球">足球
</p> 
<p>备注:
  <textarea name="bz" rows="4" id="bz">练习生</textarea>
  </p>
<p>
  <input type="submit" name="tj" id="tj" value="提交">
  <input type="reset" name="cz" id="cz" value="重置">
  <br>
</p>
</form>

</body>
</html>

代码完

跳出网页doregist代码:

<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("gb2312");
String yhm=request.getParameter("yhm");
String mm=request.getParameter("mm");
String xb=request.getParameter("xb");
String nl=request.getParameter("nl");
String tc[]=request.getParameterValues("tc");
String bz=request.getParameter("bz");
String s="";
for(int i=0;i<tc.length;i++)
{
s+=tc[i]+" ";    
}
out.println("用户名:"+yhm+"<br>");
out.println("密码:"+mm+"<br>");
out.println("性别:"+xb+"<br>");
out.println("年龄:"+nl+"<br>");
out.println("爱好:"+s+"<br>");
out.println("备注:"+bz+"<br>");
%>
</body>
</html>

代码完

备注:

原网页regist.jsp 代码中

<form name="form1" id="form1" method="post" action="doregist.jsp">的

action="doregist.jsp"为跳转页面,    doregist.jsp可改为其他文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值