A number is entered by the client to determine whether it is a leap year
This is the JSP page (the page that provides action to the client)
<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"%> <%@ Page Import="Com.liaoyuanping.action.isLeap" %>-This is the Isleap class method referenced in Java code<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Home</title></Head><Body><formAction= "test_action.jsp">Please enter the year:<inputtype= "text"name= "Txtyear"ID= "Txtyear"><inputtype= "Submit"name= "Btnsub"ID= "Btnsub"value= "judgment"></form></Body></HTML>
Create a package named COM under src under the same project and create a Isleap class
This is the Isleap method in Java code
Packagecom.liaoyuanping.action; Public classIsleap {Private intYear ; Public intgetYear () {returnYear ; } Public voidSetyear (intYear ) { This. Year =Year ; } Public Booleanisleapyear () {return((year%100!=0 && year%4==0 | | year%400==0)?true:false); }}
Finally select the entire project right-click on Run as--and run on Server, open in browser page
JSP page +java code to determine if a leap year