1. 程式人生 > 其它 >第一次java web

第一次java web

  1. 環境搭建,執行出來一個JSP頁面,顯式hello

  2.   英文字母表
<%@ 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>
   
    <title>My JSP 'index.jsp' starting page</title>
	
  </head>
  
  <body>
     <p>英文字母是:</p>
    <% 
    for(char a='A';a<='Z';a++){
    
             out.print(a+"("+(char)(a+32)+")"+"  ");
    }      
    %>
    
    <br>
  </body>

</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>
   
    <title>My JSP 'index.jsp' starting page</title>
	
  </head>
  
  <body>
    <% 
   for(int j=1;j<=9;j++){
    for(int i=1;i<=j;i++){
    int n=i*j;
    out.print(i+"x"+j+"="+n+" ");
    }
    out.print("<br>");
    } 

    %>
    
    <br>
  </body>

</html>