Related knowledge:
(1) Built-in objects
I. Use of the request
Example 1: Simple login Interface for information
Example 2: Get multi-valued information, such as hobbies
Example 3: Implementing a jump to get object information
Second, to achieve user login
(1) Get login information
(2) Information verification processing
(3) Different pages display login information
Third, the realization of user messages
User message implementation: To implement the user message with the main frame, the display of information also contains the main frame
(1) message.html
<script type= "Text/javascript" >
var s= "1234567";
function changecity () {
Defining arrays
var citylist = new Array ();
citylist[0]=[' Nanjing ', ' Wuxi ', ' Xuzhou ', ' Changzhou ', ' Nantong ', ' Lianyungang ', ' Huaian ', ' Yancheng ', ' Yangzhou ', ' Zhenjiang ', ' Taizhou ', ' Suqian '];
citylist[1]=[' Hangzhou ', ' Ningbo ', ' Wenzhou ', ' jiaxing ', ' Huzhou ', ' Shaoxing ', ' Jinhua ', ' Quzhou ', ' Zhoushan ', ' Taizhou ', ' Yeosu ';
citylist[2]=[' Fuzhou ', ' Xiamen ', ' Putian ', ' sanming ', ' Quanzhou ', ' Zhangzhou ', ' nanping ', ' Longyan ', ' Ningde '];
citylist[3]=[' Changchun ', ' Jilin ', ' siping ', ' Liaoyuan ', ' Tonghua ', ' Bss ', ' Songyuan ', ' Baicheng ', ' Yanbian '];
Gets the index number of the province option, such as Sichuan Province 1, more than the corresponding array index number 1
var pindex=document.myform.selprovince.selectedindex-1;
var NewOption1;
document.myform.selcity.options.length=0;
for (Var j in Citylist[pindex]) {
Newoption1=new Option (Citylist[pindex][j], citylist[pindex][j]);
Document.myform.selCity.options.add (NewOption1);
}
}
function Isemail (Element) {
Return (
Element.value.indexOf ("@")! =-1 &&
Element.value.indexOf (".")! =-1);
}
</script>
<div class= "Fkly" >
<form action= "index.jsp?type=msg" onsubmit= "return check ();" method= "Post" name= "MyForm" class= "Form_css" >< Table width= "100%" border= "0" >
<tr>
<TD width= "20%" > Message title </td>
<TD width= "31%" ><input name= "title" type= "text" id= "title"/></td>
<TD class= "title" Width= "57%" >* must be filled in </td>
</tr>
<tr>
<td> name </td>
<td><input name= "username" type= "text" id= "username"/></td>
<TD class= "username" >* must be filled in, 4-16-bit, content not public </td>
</tr>
<tr>
<td> Sex </td>
<td><input name= "Sex" style= "Border:none; type=" Radio "value=" Man "checked/>
Man
<input name= "Sex" style= "Border:none; type=" Radio "value=" Woman "/>
Women </td>
<td> </td>
</tr>
<tr>
<td> Cities </td>
<td><select name= "selprovince" id= "selprovince" onchange= "changecity ()" >
<option>--Please select the province--</option>
<option value= "Jiangsu province" > Jiangsu Province </option>
<option value= "Zhejiang province" > Zhejiang province </option>
<option value= "Fujian province" > Fujian province </option>
<option value= "Jilin Province" > Jilin Province </option>
</select></td>
<td><select name= "selcity" id= "selcity" >
<option>--Please select City--</option></select></td>
</tr>
<tr>
<td> Contact e-mail </td>
<td><input name= "Email" type= "text" id= "email"/></td>
<td>* must be completed, the content is not public </td>
</tr>
<tr>
<td> Telephone </td>
<td><input name= "Telephone" type= "text" id= "Telephone"/></td>
<td> Web pages will not be published </td>
</tr>
<tr>
<td> Message Content </td>
<TD colspan= "2" ><textarea name= "content" cols= "rows=" 8 "> </textarea></td>
</tr>
<tr>
<td> </td>
<td><input type= "Submit" class= "BTN1" name= "Submit" value= "Submit"/></td>
<td><input class= "BTN1" type= "reset" name= "reset" value= "reset"/></td>
</tr>
</table>
</form>
(2) Right add information
<%}else if (type.equals ("message")) {%>
<jsp:include page= "message.html" ></jsp:include> fill in the Message information page
<%}else if (type.equals ("MSG")) {%>
<jsp:include page= "msg.jsp" ></jsp:include> Display message Information page
(3) msp.jsp page to achieve the collection of messages, can contain Chinese characters, and display information
Collect message information:
<% @page contenttype= "Text/html;charset=utf-8"%>
<%
Request.setcharacterencoding ("Utf-8");
String title = Request.getparameter ("title");
String username = request.getparameter ("username");
String sex = request.getparameter ("Sex");
String City = request.getparameter ("Selprovince")
+request.getparameter ("selcity");
String email = request.getparameter ("email");
String telephone = request.getparameter ("Telephone");
String content = request.getparameter ("content");
%>
Show Message:
<table width= "100%" border= "0" >
<tbody>
<tr>
<TD width= "20%" > Message title </td>
<TD width= "31%" ><%=title%></td>
</tr>
<tr>
<td> name </td>
<td><%=username%></td>
</tr>
<tr>
<td> Sex </td>
<td><%=sex%></td>
</tr>
<tr>
<td> Cities </td>
<td><%=city%></td>
</tr>
<tr>
<td> Contact e-mail </td>
<td><%=email%></td>
</tr>
<tr>
<td> Telephone </td>
<td><%=telephone%></td>
</tr>
<tr>
<td> Message Content </td>
<td><%=content%></td>
</tr>
</tbody>
</table>
Iv. Use of application
(1) Example: Production Site counter (session, Application Mode)
(2) Application implement small message board
This article is from the "Learn Without thinking" blog, please be sure to keep this source http://dyzyxy.blog.51cto.com/944775/1619060
JSP fourth lesson: Built-in object usage