jsp-tutorialsmade

JSP program to check leap year or not

Here is another JSP program to check leap year, you will learn the below JSP tricks from this program:

1. Retrieve the value from HTML form in JSP.
2. Check if the entered value is numeric in JSP.
3. Convert string to integer in JSP.
4. Using multiple IF Conditions in JSP.

JSP script to find leap year:

The code is self explanatory, read the comments in the script. This is a single page JSP web application, not a JSP & Servlet web application.

To find the leap year, these are the conditions,

1. Year should be evenly divisible by 4 (year % 4 == 0)
2. AND (&&) Year should not be evenly divisible by 100 (year % 100 != 0)
3. OR (||) year should be evenly divisible by 400 (Year % 400 == 0)

if both the 1st AND 2nd condition is true OR 3rd is true then it is a Leap year.

Enjoy learning. Good luck.

Related Posts

Leave a Reply