/* 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. <%@  page 

2. import="java.lang.Math , java.lang.String" 

3. %> 

4. <%@  page 

5. import="java.lang.Integer" 

6. %> 

7.  

8. <% 

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

10.  

11.   rand = rand & 0x00FFFFFF ; 

12.  

13.   String strhex = Integer.toHexString ( rand ) ; 

14. %> 

15.  

16. <HTML

17.  

18. <HEAD

19.  

20. <TITLE

21. JSP Scriptlet 

22. </TITLE

23.  

24. </HEAD

25.  

26. <BODY  BGCOLOR = "#<%=strhex  %>"

27.  

28. <h1

29. This is strhex : <%= strhex %> . 

30. </h1

31.  

32. </BODY

33. </HTML

34.  

35. ===== Generated servlet source code ============= 

36.  

37. ............ 

38.  public void _jspService ( HttpServletRequest request, HttpServletResponse  response) 

39.     ........... 

40.     out.write("This is strhex : "); 

41.     out.print( strhex ); 

42.  ............ 

43.