struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Corbin <jonboy...@yahoo.com>
Subject generic token manager?
Date Sat, 25 Aug 2001 00:55:41 GMT
I am currently working on a struts project which
requires the use of tokens to assure that users don't
submit the same data twice.  Since I need this
functionality for many different Actions, I am trying
to write a generic TokenManager that can issue and
verify tokens for all of my different actions.

My current model is relatively simple.  For each
action I want to use the TokenManager for, I create an
entry in the struts-config.xml file with the
appropriate forwards, along with a parameter which
tells TokenManager what key to store the token
attribute under.  So for each TokenManager usage, I
have three forwards: form, action, and failure.

form issues a token, then forwards to a form jsp.

action forwards to another action which performs the
actual work

and failure forwards to an error jsp.

My problem is that I am having trouble figuring out
how to direct each request without making
modifications to my form jsps and Action classes. 
Optimally, I want all the token oriented code to take
place in the TokenManager, with the jsps and Action
classes not having to worry about them at all.

My first idea was to first check for the presence of a
token.  If a valid token is present, then the request
can be forwarded to the action.  Not a problem.  Then
I could simply check whether the ActionForm was
populated from a form or not.  If it was populated,
then I would forward to the error jsp.  If it wasn't,
then I would forward to the form.  This is where I'm
stuck.

How do I tell if the ActionForm has been populated
from a form or not?  This code can't cast the
ActionForm to a specific class, because it needs to
work for all ActionForms.  When I first began this
undertaking, I thought that if there was not html form
with which to populate the input bean, then
ActionServlet would send null as the ActionForm
parameter.  Unfortunately for me this was not the
case, and ActionServlet instead sent a blank
ActionForm.  But as far as I can tell, there is no way
to tell that it is blank.  Without this information,
my simple model doesn't work, and I am forced to a
much more complicated model to perform a very simple
function.

Is there any way to get this information?  Is there a
better way to accomplish what I'm trying to do?  Has
anyone done anything like this before?  Does my
explanation of the problem make any sense whatsoever?

Help is greatly needed, and will be greatly
appreciated.  Thanks in advance.  And even if you
can't help, thanks for reading this extra long post =]

Jonboy Corbin (confused struts user extraordinaire)

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Mime
View raw message