I'm not a fan of putting java code in your jsp.
I'd use a static method and a taglib to accomplish this.
Just my idea though. There are many ways to solve this problem.
public static Date addDay(Date date){
//TODO you may want to check for a null date and handle it.
Calendar cal = Calendar.getInstance();
cal.setTime (date);
cal.add (Calendar.DATE, 1);
return cal.getTime();
}
functions.tld
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>functions library</description>
<display-name>functions</display-name>
<tlib-version>1.1</tlib-version>
<short-name>xfn</short-name>
<uri>http://yourdomain/functions.tld</uri>
<function>
<description>
Adds 1 day to a date.
</description>
<name>addDay</name>
<function-class>Functions</function-class>
<function-signature>java.util.Date addDay(java.util.Date)</function-signature>
<example>
${xfn:addDay(date)}
</example>
</function>
</taglib>