JSP (7)

Source: Internet
Author: User

In the previous tutorial, we used java. util. Date. Someone may ask: why not only use import java. util? In fact, the import statement can also be used in JSPs, but its syntax is somewhat different from that of common Java. The following is an example:
<% @ Page import = "java. util. *" %>

<HTML>


<BODY>


<%


System. out. println ("Evaluating date now ");


Date date = new Date ();


%>


Hello! The time is now <% = date %>


</BODY>


</HTML>


The first line in the above Code calls a "directive ". This JSP "directive" starts with the <% @ character. This is a "page ctictive ". This "page ctictive" can contain all introduced projects. If you want to introduce more than one project, you can use commas (,) to separate projects. For example:

<% @ Page import = "java. util. *, java. text. *" %>

There can be multiple JSP ctives Ves in "page ctictive. In addition to "page ctictive", other useful ves include and taglib. In the subsequent tutorial, we will discuss taglib in detail. Here we will only discuss include direve ve.

Include directive should generally include the content of another file. The contained file can be HTML, JSP, and other types of files. The result is like that the original JSP file contains the included text. To see the include ctictive function, we create a new JSP:
<HTML>

<BODY>


Going to include myjsp. jsp... <BR>


<% @ Include file = "myjsp. jsp" %>


</BODY>


</HTML>

After writing the code, you can check the JSP in the browser. You will find that the original myjsp. jsp is included in the new JSP.

Finally, we will show the exercises in this section: modify some previous exercises and introduce the java. util package.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.