JSP from simple to deep (3) -- add dynamic content through Expressions

Source: Internet
Author: User

In our previous chapter, any HTML file can be converted into a JSP file by changing its extension to. jsp. Of course, we need to know what makes JSP useful? The answer is the ability to embed Java. Place the following text in. for example, this file is myjsp. jsp, then place the file in your JSP directory and view it in the browser. The specific code is as follows:

<HTML>

<BODY>

Hello! The time is now <% = new java. util. Date () %>

</BODY>

</HTML>

Note that the current time appears every time you reload a webpage in your browser. The character series <% = and %> is used to enclose Java expressions, which are calculated during running.

In this case, JSP is used to generate dynamic HTML webpages to respond to user actions.

Well, after the tutorial is over, you 'd better make an exercise: compile a JSP for different System attributes to output. the value returned by getProperty, such as java. version, java. home, OS. name, user. home and user. dir and so on.

Related Article

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.