Need help with Struts Interceptor/session problem.

2008-02-20 Thread daveck

Hi,
I have a BillingInterceptor that throws up a Confirmation Screen after
submitting the input parameters and before processing the action. I am using
the session to hold the parameter map so it's available to the action after
the user Confirms their purchase. I have confirmed that the PARMS is being
stored in the session.  Sometimes PARMS manages to keep its value, and
sometimes the value disappear. This seems to have something to do with the
weather or the alignment of the stars.  I see absolutely no rhyme or reason
for why it only works sometimes! I've been struggling with this off and on
for weeks.  Thanks to those who have tried to help with this issue in the
past.  Any more ideas would be greatly appreciated!


BillingInterceptor.java:

public class BillingInterceptor extends AbstractInterceptor implements
StrutsStatics {

private static final String URL_GOING_TO = URL_GOING_TO;

public String intercept (ActionInvocation invocation) throws Exception {

ActionContext context = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest)
context.get(HTTP_REQUEST);
HttpSession session =  request.getSession(false);

if ((request.getParameter(CONFIRM_SCREEN) != null) 
(request.getParameter(CONFIRM_SCREEN).equals(TRUE))) {

String urlGoingTo = invocation.getProxy().getNamespace()+
invocation.getProxy().getActionName()+
.action;

session.setAttribute(URL_GOING_TO, urlGoingTo);
session.setAttribute(PARMS, request.getParameterMap());

return confirm;
} else {
Object action = invocation.getAction();
if (action instanceof BillingAware) {
if (session.getAttribute(PARMS) != null) {
BeanUtils.populate(action, (Map)
session.getAttribute(PARMS));
session.setAttribute(PARMS, null);
}
}
return invocation.invoke();
}
}
}


confirm.jsp

%@ taglib prefix=s uri=/struts-tags%
html
headtitleConfirm/title/head
body

table width=750trtd align=center

h2Please confirm purchase./h2
br
pThis could take several minutes depending on the request./p

s:form action=%{#session.URL_GOING_TO} method=post
s:submit value=Confirm align=center
s:param name=colspan value=%{2} /
s:param name=align value=%{'center'} /
/s:submit

/s:form


/td/tr/table


/body
/html

My interceptor-stack:

interceptor-stack name=defaultLoginStack
interceptor-ref name=servlet-config/
interceptor-ref name=billing/
interceptor-ref name=params/
interceptor-ref name=login/
interceptor-ref name=prepare/
interceptor-ref name=chain/
interceptor-ref name=model-driven/
interceptor-ref name=fileUpload/
interceptor-ref name=static-params/
interceptor-ref name=params/
interceptor-ref name=conversionError/
interceptor-ref name=validation

execute

/interceptor-ref
interceptor-ref name=workflow

execute

/interceptor-ref
/interceptor-stack
-- 
View this message in context: 
http://www.nabble.com/Need-help-with-Struts-Interceptor-session-problem.-tp15598155p15598155.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Struts Interceptor/session problem.

2008-02-20 Thread Dave Newton
--- daveck [EMAIL PROTECTED] wrote:
 Sometimes PARMS manages to keep its value, and sometimes 
 the value disappear. 

I don't see anything immediately obvious; IIRC you had already checked the
session ID to make sure you were always dealing with the same session,
correct? Have you done extensive logging / tracing / etc. to make sure the
value of PARMS in the session is getting set *only* when you believe it
should be (this is what I would be most suspicious of first)?

That said, I'm pretty uncomfortable with this use of an interceptor: is this
functionality really required across broad swaths of your application? Is the
order not stored in some application-specific object that could be stored in
the session (or somewhere else) then retrieved again in a confirmation
action?

Dave


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Struts Interceptor/session problem.

2008-02-20 Thread daveck

I've done some pretty extensive troubleshooting, but will try and expand on
it.
The product is a generated and delivered (as a pdf) right after the user
clicks on the Confirm button.
I thought that the use of an interceptor for this purpose was ideal, but I'm
a Struts novice and far from an expert Java programmer.  Can you explain why
the use of an interceptor is not the right way to go about this?
Thanks!


newton.dave wrote:
 
 --- daveck [EMAIL PROTECTED] wrote:
 Sometimes PARMS manages to keep its value, and sometimes 
 the value disappear. 
 
 I don't see anything immediately obvious; IIRC you had already checked the
 session ID to make sure you were always dealing with the same session,
 correct? Have you done extensive logging / tracing / etc. to make sure the
 value of PARMS in the session is getting set *only* when you believe it
 should be (this is what I would be most suspicious of first)?
 
 That said, I'm pretty uncomfortable with this use of an interceptor: is
 this
 functionality really required across broad swaths of your application? Is
 the
 order not stored in some application-specific object that could be stored
 in
 the session (or somewhere else) then retrieved again in a confirmation
 action?
 
 Dave
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Need-help-with-Struts-Interceptor-session-problem.-tp15598155p15599632.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Struts Interceptor/session problem.

2008-02-20 Thread Dave Newton
--- daveck [EMAIL PROTECTED] wrote:
 The product is a generated and delivered (as a pdf) right after the user
 clicks on the Confirm button.

 I thought that the use of an interceptor for this purpose was ideal, but
 I'm a Struts novice and far from an expert Java programmer.  Can you
 explain why the use of an interceptor is not the right way to go about
this?

I'm definitely not saying it's *wrong*, I'm just saying I would question it.

The idea behind interceptors (IMO only, of course!) is that they are best
used to encapsulate broad functionality across the entire system (or portions
of it).

For example, large portions of a web app need validation flow control, type
conversion of request parameters to action properties, etc.

I don't know how your application is set up, but many webapps have a single
shopping-cart-like action that handles checkout, which might involve
confirmation, after which any deliverables would be returned to the user.

I (again, this is just me) don't see any point to using an interceptor for
this: I'd have a shopping cart (or whatever) action. Upon moving through that
action I'd have a confirmation action that re-displays my order. After that
I'd have the action that actually delivers whatever it is (in your case a
PDF, could be actual order submission, a thank you page, whatever).

It's a very tightly-focused use-case, hence an interceptor is adding an
additional layer of complexity and configuration that is just as easily (or,
more likely, easier) handled with an interim action that handles
confirmation and the next step in the process.

I can't overstate enough that I have no idea how your application is
designed--it's possible an interceptor *is* the best way to handle your
needs, but I'm having trouble coming up with a reason why it would be better
than just using another action, which would also probably eliminate the
problem you're currently experiencing.

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Struts Interceptor/session problem.

2008-02-20 Thread daveck


newton.dave wrote:
 
 
 I can't overstate enough that I have no idea how your application is
 designed--it's possible an interceptor *is* the best way to handle your
 needs, but I'm having trouble coming up with a reason why it would be
 better
 than just using another action, which would also probably eliminate the
 problem you're currently experiencing.
 
 

In our situation, some products are free while others are not.  There's an
interceptor stack for each. All are dynamically generated immediately as an
html page or a pdf.  An order is only generated for the products that aren't
free.  For those, once the page is delivered successfully, an order is
generated and the customers account (already established) is charged.  The
BillingInterceptor is only used for the confirmation.  Maybe I should call
it ConfirmationInterceptor.
Does an interceptor make more sense in this case?  You've got me thinking. 
Thanks.
-- 
View this message in context: 
http://www.nabble.com/Need-help-with-Struts-Interceptor-session-problem.-tp15598155p15600866.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Struts Interceptor/session problem.

2008-02-20 Thread Dave Newton
--- daveck [EMAIL PROTECTED] wrote:
 In our situation, some products are free while others are not.  There's an
 interceptor stack for each. All are dynamically generated immediately as an
 html page or a pdf.  An order is only generated for the products that
 aren't free.  For those, once the page is delivered successfully, an order
is
 generated and the customers account (already established) is charged.  The
 BillingInterceptor is only used for the confirmation.  Maybe I should call
 it ConfirmationInterceptor.
 Does an interceptor make more sense in this case? 

Not to me. It's just normal order processing: used in only one place (order
processing), doesn't encompass any functionality needed anywhere else, and
doesn't require any interceptor functionality. I'd just redirect to a
confirmation action when necessary.

Dave


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]