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

首頁 > 編程 > JSP > 正文

新手入門:JSP基本語法與簡單表單處理

2024-09-05 00:19:39
字體:
供稿:網(wǎng)友

jsp語法:

jsp指令元素

(1)include:導(dǎo)入其它文件夾

(2)page:

language:用什么語言,只能為java

contenttype:mime類型

import:導(dǎo)入java包

(3)taglib:自定義標簽庫

jsp常用標準元素

(1)jsp:forward:跳轉(zhuǎn)到其它頁面

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

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

(4)jsp:param:參數(shù)傳值

jsp內(nèi)置對象

(1)request:常用方法

getparameter():提取表單元素的值

getremoteaddr():獲取客戶端ip值

(2)response:

sendredirect():重定向到其它網(wǎng)頁

setcontenttype();設(shè)置mime值

(3)out:向網(wǎng)頁輸出

(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="美術(shù)">美術(shù)<input type=checkbox name=tch3 value="音樂">音樂</td></tr><tr><td>專業(yè):</td><td><select name=ty><option value="計算機">計算機</option><option value="文學(xué)">文學(xué)</option><option value="數(shù)學(xué)">數(shù)學(xué)</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("專業(yè)"+ty+"<br>");out.print("留言"+tl+"<br>");%></body>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿勒泰市| 天峻县| 南溪县| 上杭县| 南昌市| 星子县| 马山县| 长兴县| 宁国市| 双牌县| 乡城县| 稻城县| 石狮市| 遂平县| 陆丰市| 仙游县| 库尔勒市| 肥乡县| 宜川县| 安乡县| 综艺| 临武县| 六枝特区| 延津县| 林芝县| 南汇区| 洪雅县| 白沙| 土默特右旗| 六安市| 进贤县| 东宁县| 齐齐哈尔市| 鄂托克前旗| 公主岭市| 华亭县| 清徐县| 蒙城县| 庆元县| 汕尾市| 应城市|