- <%@ page language="java" pageEncoding="gbk"%>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>My First JSP</title>
- </head>
- <body>
- <%out.println("Hello, There"); %><br/>
- 你好,jsp
- </body>
- </html>
二
- <!-- Using a Literal -->
- <%@ page language="java" pageEncoding="gbk"%>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>My First JSP</title>
- </head>
- <body>
- <h1>Using a Literal</h1>
- <%out.println("Hello, There"); %><br/>
- 你好,jsp
- </body>
- </html>
3 table cellpadding(in cell,text to cell border) cellspacing(between cells & between cell and table border)
- <%@ page language="java" import="java.io.*,java.text.*,java.util.*" pageEncoding="gbk"%>
- <%@ page session="false" %>
- <%-- Prints a conversion table of miles per gallon
- to kilometers per liter --%>
- <%!
- private static final DecimalFormat FMT = new DecimalFormat("#0.00");
- private static final double CONVERSION_FACTOR = 2.352145;
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Convertion Table</title>
- </head>
- <body>
- <center>
- <h1>Fuel Efficiency Conversion Chart</h1>
- <table border='1' cellpadding='3' cellspacing='0'>
- <tr>
- <td>Kilometers per Liter</td>
- <td>Miles per Gallon</td>
- </tr>
- <%
- for(double kmpl=5; kmpl<=20; kmpl+=1.0){
- double mpg=kmpl*CONVERSION_FACTOR;
- %>
- <tr>
- <td align="right"><%=FMT.format(kmpl) %></td>
- <td align="right"><%=FMT.format(mpg) %></td>
- </tr>
- <%} %>
- </table>
- </center>
- </body>
- </html>