issue accessing Date object from within a scriptlet embedded in JSP



True to bad style, I'm writing a piece of JSP right now where there's
a bit of actual code scriptlet embedded with <% ... %> tags now.

In the jsp above that scriptlet I'm working with 2 objects of
java.util.Date, called inDate and outDate. When I'm trying to access
the different objects er values or whatever within them, I'm using
standard inDate.minutes and etc. to attempt to do tests on them. Is
there something special that I need to know about accessing this kind
of object from within an embedded scriptlet? I'm getting a server log
error of
An error occurred at line: 169 in the jsp file: /reports.jsp
inDate.hours cannot be resolved or is not a field

When I access that section now; debugging code above the scriptlet has
proven that inDate & outDate are getting their proper values in the
JSP code, though.

Here's a little bit of the code; I'm pretty sure this issue is just
something that I don't understand about either the scope of these
objects (declared at the top of the same JSP page) or how much access
an embedded scriptlet has to variables declared in JSP:

<fmt:parseDate var="inDate" value="${punch.starttime}"
pattern="yyyy-MM-dd HH:mm:ss" />
<fmt:parseDate var="outDate" value="${punch.endtime}" pattern="yyyy-
MM-dd HH:mm:ss" />

<%
int totalMinutes = 0, units = 0;
if (inDate.hours != outDate.hours)
totalMinutes = (outDate.hours - inDate.hours) * 60;
totalMinutes += (outDate.minutes - inDate.minutes);

if ((totalMinutes >= 8) && (totalMinutes <= 22))
units = 1;
else if (totalMinutes >= 23) {
units = 1;
totalMinutes -= 22;
do {
units += 1;
totalMinutes -= 15;
} while (totalMinutes > 0);
}
%>


I would be very grateful if anybody could help point me in the right
direction on this issue.

Damon Getsman
.



Relevant Pages

  • Re: JSP BEAN RETRIEVAL
    ... He means that the presence of scriptlet in a JSP is a "bad" mark in a ... It presents maintenance difficulties, and obviates the ... natural separation of view artifacts from logic artifacts. ... scriptlet in a JSP. ...
    (comp.lang.java.programmer)
  • Re: Static imports in JSP pages
    ... I've got very little code in the JSP at all, ... not direct scriptlet. ... NewsMaestro v. 4.0.5 - Way Too Cool has been released. ... Job list improvements for new installations having no jobs ...
    (comp.lang.java.programmer)
  • Re: param-name elements for JSPs?
    ... Even using scriptlet, which you shouldn't do, you could've used the ... (some Java EE containers don't need the c:out tag to output this.) ... which can use with a JSP? ... ask because if a JSP is a servlet, does it not also have ...
    (comp.lang.java.help)
  • Re: Static imports in JSP pages
    ... I've got very little code in the JSP at all, ... As a general rule, and of course there are exceptions, JSPs should contain only markup and custom tags, not direct scriptlet. ... Such behavior ruin an otherwise fantastic forum for both newcomers and professionals. ... To compare Lew, or anyone else, to something that's got to do with Nazism is just silly. ...
    (comp.lang.java.programmer)