first, Create a JavaBean
Userbean.java
1 packagejsp.test;2 3 public classUserBean {4 5 PrivateString userName;6 PrivateString pwd;7 PrivateString name;8 PrivateString gender;9 Private intage ;Ten PrivateString email; one PrivateString tel; a PrivateString mphone; - publicString getusername () { - returnuserName; the } - public voidsetusername (String UserName) { - this. UserName =userName; - } + publicString getpwd () { - returnpwd; + } a public voidsetpwd (String Pwd) { at this. PWD =pwd; - } - publicString getName () { - returnname; - } - public voidsetName (String Name) { in this. Name =name; - } to publicString getgender () { + returngender; - } the public voidSetgender (String Gender) { * this. Gender =gender; $ }Panax Notoginseng public intgetage () { - returnage ; the } + public voidSetage (intage ) { a this. Age =age ; the } + publicString getemail () { - returnemail; $ } $ public voidsetemail (String Email) { - this. email =email; - } the publicString Gettel () { - returntel;Wuyi } the public voidSettel (String Tel) { - this. Tel =tel; wu } - publicString getmphone () { about returnmphone; $ } - public voidSetmphone (String mphone) { - this. Mphone =mphone; - } a + the -}
View Code
second, the life cycle of Javabean---------1.page range
Counter.java
1 packagebean;2 3 public classCounter {4 publicCounter () {5 }6 Private intCount=0;7 public intGetCount () {8 returncount;9 }Ten public voidSetCount (intCount) { oneCount =count; a } - -}
View Code
usingcounter.jsp
1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<! DOCTYPE HTML public "-//w3c//dtd HTML 4.01 transitional//en" "http://www.w3.org/TR/html4/loose.dtd" >456<meta http-equiv= "content-type" content= "text/html; Charset=utf-8 ">7<title>page type of life cycle </title>89<body>Ten<jsp:usebean id= "count" scope= "page"class= "bean. Counter "/> one<font color= "blue" >Show:page</font><br><br> a<br> you is the -<font color=green> -<jsp:getproperty name= "count" property= "counter"/></font>Viewer the</body> -View CodeThe value of using the page counter is always kept at 1, not updated:
third, the life cycle of javabean-----------2.request
JSP review and finishing (fri) JavaBean