JSP web应用程序开发教程实验一

编码统一utf-8

文件名:a.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  
  
    
    
    
    <%  
        int num = Integer.parseInt(request.getParameter("num"));  
        out.println(num+"的平方是:"+num*num);  
     %>  
    
  

文件名:b.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  
  
    
    
    
       
          
       
    
  

文件名:ex201.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  
  
  
  
  
    <%  
        Date date = new Date();  
        int hour = date.getHours();  
        int minute = date.getMinutes();  
        int second = date.getSeconds();  
        
        if (hour >= 0 && hour < 12) {  
            out.println("早上好!");  

        } else if (hour >= 12 && hour < 19) {  
            out.println("下午好!");  
 
        
        } else {  
            out.println("晚上好!");  
       
        }  
    %>  
  
  

文件名:test1.jsp

<%@ page contentType="text/html;charset=utf-8" %>
<%
request.setCharacterEncoding("utf-8");
String strUserName = "";
strUserName = (String)request.getParameter("UserID");
if(strUserName.equals("张三")){
    out.println("你好" + strUserName);
}else{
    out.println("名称错误");
}

%>

姓名:<%=strUserName%>

文件名:test2.jsp

<%@ page contentType="text/html;charset=utf-8" %>

    

姓名:

你可能感兴趣的:(JSP web应用程序开发教程实验一)