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.