Java/JSP/HTML Output
Содержание
Celsius Fahrenheit Table Jsp
<source lang="java">
<%--
Copyright (c) 2002 by Phil Hanna All rights reserved. You may study, use, modify, and distribute this software for any purpose provided that this copyright notice appears in all copies. This software is provided without warranty either expressed or implied.
--%> <%@ page session="false" %>
Celsius | Fahrenheit |
---|---|
" + c + " | "); out.print("" + f + " | "); out.print("
</source>
JSP HTML Table
Output HTML
<source lang="java">
<%--
Copyright (c) 2002 by Phil Hanna All rights reserved. You may study, use, modify, and distribute this software for any purpose provided that this copyright notice appears in all copies. This software is provided without warranty either expressed or implied.
--%> <%@ page session="false" %> <%
out.println("out
is an ");
out.println(out.getClass().getName());
out.println(" object.");
%>
</source>
Output Simple HTML Tag Jsp
Print ASCII Table Jsp
<source lang="java">
<%--
Copyright (c) 2002 by Phil Hanna All rights reserved. You may study, use, modify, and distribute this software for any purpose provided that this copyright notice appears in all copies. This software is provided without warranty either expressed or implied.
--%> <%@ page session="false" %> <html> <body>
ASCII Table
"); | ");
sb.append(Integer.toHexString(col));sb.append(" | ");
}
sb.append("
---|---|
");
sb.append(Integer.toHexString(row));sb.append(" | ");
for (int col = 0; col < 16; col++) {
char c = (char)(row * 16 + col);
sb.append("");
sb.append(c);sb.append(" | ");
}
sb.append("
</body> </html>
</source>
Prints a conversion table of miles per gallon to kilometers per liter
<source lang="java">
<%--
Copyright (c) 2002 by Phil Hanna All rights reserved. You may study, use, modify, and distribute this software for any purpose provided that this copyright notice appears in all copies. This software is provided without warranty either expressed or implied.
--%> <%@ page session="false" %> <%@ page import="java.io.*" %> <%@ page import="java.text.*" %> <%@ page import="java.util.*" %> <%-- 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;
%> <html> <head> <title>Fuel Efficiency Conversion Chart</title> </head> <body>
Fuel Efficiency Conversion Chart
Kilometers per Liter | Miles per Gallon |
---|---|
<%= FMT.format(kmpl) %> | <%= FMT.format(mpg) %> |
</body> </html>
</source>