JSP Print 99 multiplication table

Source: Internet
Author: User

First, the JSP comments

<!--visible in the client-

<%--is not visible in the client

JSP script Comment://single-line comment/**/Multiline comment

Second, the JSP statement

<%! %>

Third, JSP printing 99 multiplication table

Expression mode and script mode

<%@ page language= "java" import= "java.util.*" contenttype= "text/html"; Charset=utf-8 "%>
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
<base href= " <%=basePath%>

<title>my JSP ' jiujiu.jsp ' starting page</title>

<meta http-equiv= "Pragma" content= "No-cache",
<meta http-equiv= "Cache-control" content= "No-cache";
< Meta http-equiv= "expires" content= "0" >
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3"
<meta http-equiv= "description" content= "This is my page";
<!--
<link rel= "stylesheet" type= "Text/css" href= "Styles.css";
-->


<body>
<%!
Returns a 99 multiplication table, called through an expression, displayed on the page
String printmultitable () {
String s = "";
for (int i=1;i<=9;i++) {
for (int j=1;j<=i;j++) {
s+=i+ "*" +j+ "=" +i*j+ "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
s+= "<br>";
}
return s;
}
To print a 99 multiplication table using a scripted method
void PrintMultiTable2 (JspWriter out) throws exception{
for (int i=1;i<=9;i++) {
for (int j=1;j<=i;j++) {
OUT.PRINTLN (i+ "*" +j+ "=" + (i*j) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
}
Out.println ("<br>");
}
}
%>
<%=printmultitable ()%>
<br>
<% PrintMultiTable2 (out); %>
</body>

JSP Print 99 multiplication table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.