声明标记

声明标记范例

 

<%!
  String name = "Joe";
  String date = "8th April, 2002";
%>

<HTML>
  <TITLE>Declaration Tag Example</TITLE>

  <BODY>
    This page was last modified on <%= date %> by <%= name %>.
  </BODY>
</HTML>

 

 声明标记:方法

<%!
  private String getNephewName()
  {
    return "J";
  }

  private int getNephewAge()
  {
    return 3;
  }
%>

<HTML>
  <HEAD><TITLE>Declaration Tag - Methods</TITLE></HEAD>

  <%= getNephewName() %>, age <%= getNephewAge() %>, is one funny kid!

  
</HTML>
 

使用Out

<%@ page language="java" %>
<HTML>
  <HEAD><TITLE>JSP Example</TITLE></HEAD>
  <BODY>
    <H1>Quadratic Equation: y = x^2</H1>
      <TABLE BORDER="1">
        <TH>x</TH><TH>y</TH>
        <% 
          for (int i=0; i<10; i++)
            out.print("<TR><TD WIDTH='100'>" + i + "</TD><TD WIDTH='100'>" + (i*i) + "</TD></TR>");
        %>
      </TABLE>
  </BODY>
</HTML>
 

你可能感兴趣的:(html,jsp,J#)