<p>On a JSTL/JSP page, I have a java.util.Date object from my application. I need to find the day <em>after</em> the day specified by that object. I can use &lt;jsp:scriptlet&gt; to drop into Java and use java.util.Calendar to do the necessary calculations, but this feels clumsy and inelegant to me.</p>

<p>Is there some way to use JSP or JSTL tags to achieve this end without having to switch into full-on Java, or is the latter the only way to accomplish this?</p>

[{'answer_id': 74274, 'author': 'sirprize', 'author_id': 12902, 'author_profile': 'https://Stackoverflow.com/users/12902', 'pm_score': 2, 'selected': False, 'text': '<p>While this does not answer your initial question, you could perhaps eliminate the hassle of going through java.util.Calendar by doing this:</p>\n\n<pre><code>// Date d given\nd.setTime(d.getTime()+86400000);\n</code></pre>\n'}, {'answer_id': 74582, 'author': 'jodonnell', 'author_id': 4223, 'author_profile': 'https://Stackoverflow.com/users/4223', 'pm_score': 2, 'selected': False, 'text': '<p>You have to either use a scriptlet or write your own tag.  For the record, using Calendar would look like this:</p>\n\n<pre><code>Calendar cal = Calendar.getInstance();\ncal.setTime (date);\ncal.add (Calendar.DATE, 1);\ndate = cal.getTime ();\n</code></pre>\n\n<p>Truly horrible.</p>\n'}, {'answer_id': 74619, 'author': 'Mark B', 'author_id': 13070, 'author_profile': 'https://Stackoverflow.com/users/13070', 'pm_score': 1, 'selected': False, 'text': "<p>Unfortunately there is no tag in the standard JSP/JSTL libraries that I know of that would allow you to do this date calculation.</p>\n\n<p>The simplest, and most inelegant, solution is to just use some scriptlet code to do the calculation.  You've already stated that you think this is a clunky solution, and I agree with you.  I would probably write a custom JSP taglib to get this if I were you.</p>\n"}, {'answer_id': 74646, 'author': 'ScArcher2', 'author_id': 1310, 'author_profile': 'https://Stackoverflow.com/users/1310', 'pm_score': 4, 'selected': True, 'text': '<p>I\'m not a fan of putting java code in your jsp.</p>\n\n<p>I\'d use a static method and a taglib to accomplish this.</p>\n\n<p>Just my idea though. There are many ways to solve this problem.</p>\n\n<pre><code>public static Date addDay(Date date){\n   //TODO you may want to check for a null date and handle it.\n   Calendar cal = Calendar.getInstance();\n   cal.setTime (date);\n   cal.add (Calendar.DATE, 1);\n   return cal.getTime();\n}\n</code></pre>\n\n<p>functions.tld</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;\n&lt;taglib xmlns="http://java.sun.com/xml/ns/j2ee"\n  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"\n  version="2.0"&gt;\n  &lt;description&gt;functions library&lt;/description&gt;\n  &lt;display-name&gt;functions&lt;/display-name&gt;\n  &lt;tlib-version&gt;1.1&lt;/tlib-version&gt;\n  &lt;short-name&gt;xfn&lt;/short-name&gt;\n  &lt;uri&gt;http://yourdomain/functions.tld&lt;/uri&gt;\n  &lt;function&gt;\n    &lt;description&gt;\n      Adds 1 day to a date.\n    &lt;/description&gt;\n    &lt;name&gt;addDay&lt;/name&gt;\n    &lt;function-class&gt;Functions&lt;/function-class&gt;\n    &lt;function-signature&gt;java.util.Date addDay(java.util.Date)&lt;/function-signature&gt;\n    &lt;example&gt;\n      ${xfn:addDay(date)}\n    &lt;/example&gt;\n  &lt;/function&gt;\n&lt;/taglib&gt;\n</code></pre>\n'}, {'answer_id': 76166, 'author': 'Mwanji Ezana', 'author_id': 7288, 'author_profile': 'https://Stackoverflow.com/users/7288', 'pm_score': 1, 'selected': False, 'text': "<p>In general, I think JSPs should not have data logic. They should get all the data they need to display from the Controller and all their logic should be about HOW the data is displayed, not WHAT is displayed. This is usually a lot simpler and a lot less code/XML than adding a custom tag.</p>\n\n<p>And if there isn't any re-use happening, is a tiny scriptlet really that much worse than the taglib XML?</p>\n"}]
['https://Stackoverflow.com/questions/74248', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2041950/']