e1058. generating dynamic content on a jsp page.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 19 行

TXT
19
字号
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 + =
减小字号Ctrl + -
显示快捷键?