Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

JSP Declarations

Share this post!
 Vote this!

he 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;
    }
%>  more...

0 comments:

Post a Comment