Search This Blog

Sunday, 16 September 2012

Practical 36) Write a JSP Page to use JSP scripting.


Filename-FindColor.html

<html>
<body>
<form action="http://localhost:8090/wtad/def36/Scripting.jsp">
color name
<input type="text" name="color"/>
<br>
<input type="submit" />
</form>
</body>
</html>

Filename-Scripting.jsp

<html>
<body bgcolor="<%= request.getParameter("color") %>">
<h2> Scripting Example of jsp </h2>

<br>
<%! int access=0; %>
Current date and time=
<%= new java.util.Date()%>
<br>
Example of Scriplet
<br>
<%
          int myno=(int)(Math.random()*100);
%>
Random Number=
<%= myno %>
<br> visited page time=
<%= ++access %>

<%!
          private int genNumber(int no)
          {
                   java.util.Random r=new java.util.Random();
                   return r.nextInt(no);
          }
%>
<br>Number genrated is under 10=
<%= genNumber(10) %>

<br>
RequestParameter1


</body>
</html>

Output

color name  

Scripting Example of jsp


Current date and time= Tue Apr 10 23:48:45 IST 2012 
Example of Scriplet 
Random Number= 18 
visited page time= 2 
Number genrated is under 10= 8 
RequestParameter1

No comments:

Post a Comment