1. Package:
Copy codeThe Code is as follows: package PaintBrush;
/**
*
* @ Author lucifer
*/
Public class PaintBrush {
Private String curcolor = "red ";
Public String getColor (){
Return curcolor;
}
Public void setColor (String color ){
Curcolor = color;
}
}
2. JSP code:Copy codeThe Code is as follows: <% --
Document: TestSetPro
Created on:, 15:02:50
Author: lucifer
-- %>
<% @ Page contentType = "text/html" pageEncoding = "UTF-8" %>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"
Http://www.w3.org/TR/html4/loose.dtd>
<Jsp: useBean id = "brush" class = "PaintBrush. PaintBrush"/>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> JSP Page </title>
</Head>
<Body>
Original Color:
<Jsp: getProperty name = "brush" property = "color"/>
<Br>
Changed Color:
<Jsp: setProperty name = "brush" property = "color" value = "blue"/>
<Jsp: getProperty name = "brush" property = "color"/>
</Body>
</Html>
3. Output:
Original Color: red
Changed Color: blue