Am Donnerstag, 8. Januar 2004 21:58 schrieb Patrice Sicaud:
> Before I go half-cock about this, I was curious about the cleaner way
> to preload a form.
> For example, prior to authenticating users who forgot their user id,
> I need to retrieve (from the database) the list of possible secret
> questions that will be used to validate their responses (secret
> answer). So... what do I do? provide an action without corresponding
> presentation layer element? May be an FindForwardAction? Or is it
> preferable to chain 2 actions. I have read somewhere that the latter
> was not recommended. May be, it makes no difference???
> Any pointer would be appreciated...

I understand you need a rather static, global list which is to be read
from the database before presenting the login form | authenticating
the user. There are several approaches for this.

1. If your server supports Servlets 2.3, you can use a 'resource'
listener which gets the list from the database and stores it as a
Collection in Application scope. Then, you can populate your
login form with the data from this Collection. Use this if your
questions are rather 'fixed', as the listener will be reinitialized
only if the application is reloaded.

2. An alternative solution would be to write a small custom
Action which gets the list from the database, stores it in
request scope and forwards to your login page. As the
details of getting the list should be hidden from the Struts
part, this typically more or less boils down to two lines
of code (the Model call plus the one that stores the
results) plus the forward to your login form. The advantage
of this approach is that it's dynamic; if the number of
question changes, the list will be up-to-date upon each
new login attempt. The drawback is that an additional
backend call is required for each login which can be
a factor in situations of high traffic volume.

We use both these approaches depending on the
concrete scenario, and they both work well. Then,
I doubt subclassing ActionServlet might be necessary
or even recommendable here.

> Thx
> Patrice

HTH,
-- Chris.


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

Reply via email to