By: aathishankaran Viewed: 169 times Printer Friendly Format
In the previous article we had explained about the java.util.Date in the examples in the previous articles. Perhaps you wondered why we don't just import java.util.*;
is possible to use "import"
statements in JSPs, but the syntax is a little different from normal Java.
Try the following example:
<%@ page import="java.util.*" %>
System.out.println( "Evaluating date now" );
Date date = new Date();
Hello! The time is now <%= date %>
The first line in the above example is called a "directive". A JSP "directive" starts with <%@ characters.
one is a "page directive". The page directive can contain the
list of all imported packages. To import more than one item, separate the
package names by commas, e.g.
<%@ page import="java.util.*,java.text.*" %>
There are a number of JSP directives, besides the page directive. Besides the page directives, the other most useful directives are include and taglib. We will be covering taglib separately.
include directive is used to physically include the contents of another file.
The included file can be HTML or JSP or anything else -- the result is as if the
original JSP file actually contained the included text. To see this
directive in action, create a new JSP
Going to include hello.jsp...<BR>
<%@ include file="hello.jsp" %>
View this JSP in your browser, and you will see your original hello.jsp get included in the new JSP.
Most Viewed Articles (in JSP )
Latest Articles (in JSP)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews