JSP2

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


输入一个正整数:

    




 


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


<% String str=request.getParameter("number");
if(str!=null){ 
    int n=Integer.parseInt(str);
    int sum1=0;
    for(int i=1;i<=n;i++)
        sum1=sum1+i;
    %>
   

从1到<%=n %>的连续和是:<%=sum1 %>
    <% 
}
%>

JSP2_第1张图片

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>



加载文件
                          
                  
    
    


lad.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>



<%double area;
  String up=request.getParameter("up");              
  String down=request.getParameter("down");     
  String height=request.getParameter("height");  
  double u=Double.parseDouble(up);                   
  double d=Double.parseDouble(down);
  double h=Double.parseDouble(height);
  area=(u+d)*h/2;%>                                             
  

梯形面积为:<%=area %>

JSP2_第2张图片

你可能感兴趣的:(JSP2)