JSP from simple to deep (3) — adding dynamic content through expressions

In our previous chapters, any HTML file can be transformed 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 a JSP is a file with an extension, for example, this file is myjsp JSP, then place the file in your JSP directory and look at it in your browser. The following are the specific codes:

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

Note here that every time you reload a web page in the browser, it will appear the current time. The character series <% = and% > is used to circle the Java expression, which will be evaluated at run time.

Because of this, it is possible to generate dynamic HTML web pages using JSP to respond to user actions.

Well, at the end of the tutorial, you'd better do an exercise: write a JSP for different system properties to output by system The value returned by getproperty, such as Java version、java. home、os. name、user. Home and user Dir, wait.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>