JSP: Write a 9-9 multiplication table (expression method and script method)
<% @ Page language = java import = java. util. * pageEncoding = UTF-8 %>
<%
String path = request. getContextPath ();
String basePath = request. getScheme () +: // + request. getServerName () +: + request. getServerPort () + path + /;
%>
<%!
String printMultiTable1 ()
{
String s =;
For (int I = 1; I <= 9; ++ I)
{
For (int j = 1; j <= I; ++ j)
{
S + = I + * + j + = + (I * j) + & nbsp ;;
}
// Line feed
S + =
;
}
Return s;
}
Void printprintMultiTable2 (JspWriter out) throws Exception
{
String s =;
For (int I = 1; I <= 9; ++ I)
{
For (int j = 1; j <= I; ++ j)
{
Out. println (s + = I + * + j + = + (I * j) + & nbsp ;);
}
// Line feed
Out. println (
);
}
}
%>
// Expression method
9-9 multiplication table
<% = PrintMultiTable1 () %>
// Script method
9-9 multiplication table
<%= PrintMultiTable () 1%>