第一次JSP作业
1.打印Hello
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Insert title here</title> </head> <body> 26个英文字母 <br> <p> <% for(char x = 'a';x<='z';x++){ out.print(" "+x); } %></p> </body> </html>
2.打印26个字母
1 <%@ page language="java" contentType="text/html; charset=utf-8" 2 pageEncoding="utf-8"%> 3 <!DOCTYPE html> 4 <html> 5 <head> 6 <meta charset="utf-8"> 7 <title>Insert title here</title> 8 </head> 9 <body> 10 26个英文字母 <br> 11 <p> <% 12 for(char x = 'a';x<='z';x++){ 13 out.print(" "+x); 14 } 15 16 %></p> 17 </body> 18 </html>
3.打印乘法表
<%@ page language="java" import="java.util.*" pageEncoding="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"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.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"> --> </head> <body> 九九乘法表 <br> <p> <% for(int j = 1;j<=9;j++){ for(int i = 1;i<=j;i++){ int n= i*j; out.print(i+"*"+j+"="+n+" ");} out.print("<br>");} %></p> </body> </html>