首页 > 网站 > 建站经验 > 正文

JS_P基本语法与简单表单处理

2019-11-02 15:10:44
字体:
来源:转载
供稿:网友

   jsp语法:

  jsp指令元素

  (1)include:导入其它文件夹

  (2)page:

  language:用什么语言,只能为JAVA

  contentType:MIME类型

  import:导入java包

  (3)taglib:自定义标签库

  jsp常用标准元素

  (1)jsp:forward:跳转到其它页面

  (2)jsp:include:插入其它文件 eg:

  (3)jsp:plugin:插入applet小程序

  (4)jsp:param:参数传值

  jsp内置对象

  (1)request:常用方法

  getParameter():提取表单元素的值

  getRemoteAddr():获取客户端IP值

  (2)response:

  sendRedirect():重定向到其它网页

  setcontentType();设置MIME值

  (3)out:向网页输出

  (4)application

  setAttribute(String,Object)把变量的值保存在application中;

  getAttribute(String)获取保存在applicaion中的值

  removeAttribute(String)删除保存在application中的值

  (5)session

  setAttribute(String,Object)把变量的值保存在session中;

  getAttribute(String)获取保存在session中的值

  removeAttribute(String)删除保存在

  getID:获取session编号

  jsp简单表单处理

<[email protected] contentType="text/html;charset=gb2312"%>
<[email protected] language="java" %>
<html>
<head><title>表单处理</title

搞笑段子[www.62-6.com]
></head>
<form name="frm" method="GET" action="ch-show.jsp">
<table boder=0>
<tr><td>用户名:</td><td><input type=text name="Tname"></td></tr>
<tr><td>密码:</td><td><input type=password name="Tpass"></td></tr>
<tr><td>性别:</td>
<td><input type=radio name="Tsex" value="男" checked>男
<input type=radio name="Tsex" value="女">女</td>
</tr>
<tr><td>爱好:</td>
<td><input type=checkbox name=Tch1 value="体育">体育
<input type=checkbox name=Tch2 value="美术">美术
<input type=checkbox name=Tch3 value="音乐">音乐</td>
</tr>
<tr><td>专业:</td><td><select name=Ty>
<option value="计算机">计算机</option>
<option value="文学">文学</option>
<option value="数学">数学</option>
</select>
<tr><td>留言:</td><td><textarea name=Tl rows=5 cols=20></textarea></td></tr>
<tr><td><input type=submit value="用户信息"></td></tr>
</table></form>
<%
String Tname=request.getParameter("Tname");
String Tpass=request.getParameter("Tpass");
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表