/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. ========= SoftwareComponent.java ============================== 

2. package ourbeans; 

3.  

4. public class SoftwareComponent 

5.   implements java.io.Serializable 

6.

7.    private String strhex ; 

8.  

9.    public String getStrhex () 

10.    { 

11.       return strhex ; 

12.    } 

13.  

14.  

15.    public SoftwareComponent () 

16.    { 

17.      int rand = (int)( Math.random() * Integer.MAX_VALUE ) ; 

18.      rand = rand & 0x00FFFFFF ; 

19.      strhex = Integer.toHexString ( rand ) ; 

20.    } 

21.  } 

22.  

23. ======= usebean.jsp ============================== 

24. <jsp:useBean 

25.   id="tobeanornottobean" 

26.   scope="session" 

27.   class="ourbeans.SoftwareComponent" 

28. /> 

29.  

30.  

31. <HTML

32.  

33. <HEAD

34.  

35. <TITLE

36. JSP Scriptlet 

37. </TITLE

38.  

39. </HEAD

40.  

41. <BODY 

42. BGCOLOR = "# 

43. <jsp:getProperty 

44.   name="tobeanornottobean" 

45.   property="strhex" 

46. /> 

47. "> 

48.  

49. <h1

50.  <%= tobeanornottobean.getStrhex() %> 

51. </h1

52.  

53. </BODY

54. </HTML

55.  

56. ==== various : ========= 

57. <jsp:setProperty 

58.   name="somebean" 

59.   property="someprop" 

60.   value="<%= someref %>" 

61. /> 

62.  

63. <jsp:setProperty 

64.   name="somebean" 

65.   property="*" 

66. /> 

67. =========== 

68. ${ tobeanornottobean.strhex }