Tuesday, October 5, 2010

JSP Using jsp Scriptlet


Jsp-Scriptlet

A scriptlet is a set of java statement embedded in an HTML page. The statements are distinguished from their surrounding HTML by being placed between &lt % and % & gt

We can include java coding between scriptlet.

Syntax:


< statement; >



Example for Scriptlet:



Aim:

Get system hour:minute:seconds



< %@page contentType="text/html" pageEncoding="UTF-8"% >

< %@page import="java.util.Date" % >

< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

http://www.w3.org/TR/html4/loose.dtd >



< html >

< head >



< title > Example for Scriptlet < /title >

< /head >

< body >

< %

Date d=new Date();



%>

< font size="20" >

< %= d.getHours() % > : < %= d.getMinutes() % > : < %= d.getSeconds() % >

< /font >

< /body >

< /html >

Output:




















NOTE:
           Scriptlet is used to include java programming code. Scriptlet tag is alse used to declare variable.


No comments:

Post a Comment