Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Servlet being called multiple times from JSP...

Reply
Thread Tools

Servlet being called multiple times from JSP...

 
 
GfxGuy
Guest
Posts: n/a
 
      05-04-2005
Having a problem with my PTO (paid time off) web application. The flow
works like this:

pto_select_days.jsp --> pto_check.jsp --> SubmitPTO (servlet)

pto_check does the logic, checking to make sure that certain values are
correct (filled in, anyway), the bean "req" is a PTO request bean that
is automatically filled in and does the calculations for total days and
so forth...

The problem seems to lie somewhere in the JSP, where if all the values
are OK then the SubmitPTO servlet is called and everything works just
fine. If there are incorrect values, though, the errors are
displayed... and somehow the SubmitPTO servlet is called TWICE! Yet
the page is not further redirected to the output from the servlet... it
stays on this page where the errors in input are displayed. Here's
some relevent code... it checks that some days were actually selected,
that the requesting user is actually a valid user, that a phone number
where the employee can be reached is given or, for unrequested days, a
reason is given (we don't have sick days and vacation days, just "paid
time off" which is used for both, so an unrequested day is usually a
sick day, for example).

-----------

<c:set var="redirect" value="true" scope="page"/>
<c:set var="message" value="" scope="page" />
<c:set var="total_days" value="${req.total_days}" scope="page" />

<c:if test="${total_days == 0}">
<c:set var="redirect" value="false" />
<c:set var="message" value="${message}<li>No days were selected."/>
</c:if>

<c:if test="${req.rid < 1}">
<c:set var="redirect" value="false" />
<c:set var="message" value="${message}<li>Invalid user ID: ${req.id}"
/>
</c:if>

<c:if test="${empty param.phones && param.scheduled == 'true'}">
<c:set var="redirect" value="false" />
<c:set var="message" value="${message}<li>You must enter a phone
number." />
</c:if>

<c:if test="${param.scheduled == 'false'}">
<c:if test="${empty param.reason }">
<c:set var="redirect" value="false" />
<c:set var="message" value="${message}<li>Unscheduled days require a
reason." />
</c:if>
</c:if>

<c:choose>
<c:when test="${redirect}">
<%-- NOTE: this is the ONLY redirect on the page,
and yes, I tried renaming my variable something else -- %>
<c:redirect url="servlet/RequestPTO" />
</c:when>
<ctherwise>

<font size="+1">
The PTO request could not be processed because:
<font color="red">
<ul>
<cut value="${message}" escapeXml="false"/>
</ul>
<p>
</font>
<p>
Press
<input type="button" value="here" onclick="history.go(-1)">
or the back button on your browser to try again.
</font>

</ctherwise>
</c:choose>

-------------

So... there's only one "<redirect>" on the whole page, yet the servlet
gets called twice even though I see the error messages display.
Moreover, the output from the Servlet (which is just redirected to
other jsp) is never displayed... I mean, it's called TWICE!! There is
some information not being shown here, for sake of brevity, but it's
just web page stuff and getting parameters and so forth... no logic.

When I check the log, I can see that the error messages are displayed,
then it should be the end of it (I think), but then, after displaying
the reason(s) why it wouldn't submit, the servlet is called twice.

Right now, because of time, I'm switching my logic to the servlet, but
I'm not happy about that.

I'm sure it's something stupid I'm doing...

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple sproc executes 240 times slower when called from asp.net thanwhen called from QA Radu ASP .Net 7 08-28-2009 09:09 PM
WebService called by automation dll times out when being called from Navision Felix ASP .Net Web Services 1 09-29-2006 01:43 PM
onbeforeunload being called multiple times saugust@cma.com Javascript 0 08-16-2006 06:23 PM
three times copy ctor called, one ctor called, why? Apricot C++ 4 04-16-2004 07:55 AM
Why is the Constructor called 4 times but the Destructor 5 times? djskrill C++ 9 10-01-2003 07:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57