tempconvert1.jsp

来自「这是另一部分..只是供大家参考下拉..到时候有什么不明白的可以」· JSP 代码 · 共 59 行

JSP
59
字号
<!-- tempconvert1.jsp 
     A document that collects a Celsius temperature from a
     client and uses a scriptlet to convert it to Fahrenheit
     -->

<html xmlns = "http://www.w3.org/1999/xhtml">
  <head>
    <title> Temperature converter </title>
  </head>
  <body>
    <p>
      <%

// Get the Celsius temperature from the form 

         String strCtemp = request.getParameter("ctemp");
         float ftemp;

// If this is not the first request (there was a form value),
// convert the value to Fahrenheit
if (strCtemp != null) {  
           ftemp = 1.8f * Integer.parseInt(strCtemp) + 32.0f;
       %>

<!-- Use an expression to display the value of the 
     Fahrenheit temperature -->

     Fahrenheit temperature:

       <%= ftemp %>

<!-- Code for the end of the then clause compound 
     statement -->

       <%
         }  //** end of if (strCtemp != ...
         else {
       %>

<!-- This is the first request, so display the form
     to collect the Celsius temperature -->

       <form action = "tempconvert1.jsp" method = "get" >
         Celsius temperature: 
         <input type = "text" name = "ctemp" />
         <input type = "submit" />
       </form>
     </p>

<!-- Code for the end of the else clause compound
     statement -->

     <%
         } //** end of else clause
     %>
  </body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?