📄 e1058. generating dynamic content on a jsp page.txt
字号:
The primary method for generating dynamic content on a JSP page is through the use of JSP expressions. A JSP expression is essentially a Java expression that is automatically converted to a String and written to the output stream. Here are some examples of JSP expressions:
The value of Pi is: <%= Math.PI %>
A random number between 1 and 100 is: <%= (int)(Math.random()*100)+1 %>
The value of the "p" request paramter is: <%= request.getParameter("p") %>
Today is: <%= new java.text.SimpleDateFormat("EEEE").format(new java.util.Date()) %>
Dynamic content can also be generated from a scriptlet by using out to write to the output stream. Here are some examples:
<%
if (Math.random() > .5) {
out.println("<b>You win!</b>");
} else {
out.println("Sorry, you lose. Try again.");
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -