国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

JSP基本語法與簡單表單處理

2024-09-05 00:20:37
字體:
來源:轉載
供稿:網友

  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簡單表單處理

<%@page contenttype="text/html;charset=gb2312"%>
<%@page language="java" %>
<html>
<head><title>表單處理</title></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");
string tsex=request.getparameter("tsex");
string tlove1=request.getparameter("tch1");
string tlove2=request.getparameter("tch2");
string tlove3=request.getparameter("tch3");
string ty=request.getparameter("ty");
string tl=request.getparameter("tl");
byte b1[]=tsex.getbytes("iso-8859-1");
tsex=new string(b1);
if(tlove1==null)
{
tlove1="";
}
else
{
byte b2[]=tlove1.getbytes("iso-8859-1");
tlove1=new string(b2);
}
if(ty==null)
{
ty="";
}
else
{
byte b5[]=ty.getbytes("iso-8859-1");
ty=new string(b5);
}
if(tlove2==null)
{
tlove2="";
}
else
{
byte b3[]=tlove2.getbytes("iso-8859-1");
tlove2=new string(b3);
}
if(tlove3==null)
{
tlove3="";
}
else
{
byte b4[]=tlove3.getbytes("iso-8859-1");
tlove3=new string(b4);
}
 out.print("你的信息是:"+"<br>");
out.print("用戶名"+tname+"<br>");
out.print("密碼"+tname+"<br>");
out.print("性別"+tsex+"<br>");
out.print("愛好"+tlove1+tlove2+tlove3+"<br>");
out.print("專業"+ty+"<br>");
out.print("留言"+tl+"<br>");
%>
</body>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蒙城县| 林州市| 苗栗县| 乌海市| 辛集市| 莎车县| 多伦县| 连江县| 安塞县| 大方县| 鄱阳县| 和平区| 霍州市| 庄浪县| 临桂县| 吉隆县| 湟源县| 青浦区| 息烽县| 邻水| 曲周县| 岳西县| 广灵县| 河北省| 江油市| 雅江县| 达孜县| 曲阜市| 临沂市| 扶余县| 黄石市| 临颍县| 金华市| 贺州市| 洛川县| 象山县| 闽清县| 积石山| 和顺县| 宜川县| 微博|