Showing posts with label JSP Declarations. Show all posts
Showing posts with label JSP Declarations. Show all posts

Thursday, August 22, 2013

Basic Lesson 7:- Declarations in Jsp

The JSP you write turns into a class definition.  All the scriptlets you write are placed inside a single method of this class.
You can also add variable and method declarations to this class.  You can then use these variables and methods from your scriptlets and expressions.
To add a declaration, you must use the <%! and %> sequences to enclose your declarations, as shown below.
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%!
    Date theDate = new Date();
    Date getDate()
    {
        System.out.println( "In getDate() method" );
        return theDate;
    }
%>
Hello!  The time is now <%= getDate() %>
</BODY>
</HTML>