On 6/21/05, Rafael Taboada <[EMAIL PROTECTED]> wrote:
> Hi folks. I need to store some objects in session scope in order to use
> around the application. What is the best way to do that?
>  I need to have TAX value in any place of the application. I thought about
> creating an Action class y call a method which it get TAX data from database
> and then put the value in session scope.
>  But when I call for first time index.jsp, it has to call that method... How
> can I do that?. Is it an appropiate way?
>  I don't know how to call a method inside an action class from a jsp.

Rafael, do you remember, that it is not a good Struts practice to call
jsp directly? It is better to call action, which would forward to jsp.

About storing data somewhere in Struts instead of using session or
application scope directly. When I started to use Struts, I also
wanted to use Struts objects exclusively. I had some sort of fear of
using non-Struts structures :) But in reality Struts is a very thin
layer on top of JSP/servlets. Struts request processor is a servlet,
and each action form that you declare in struts-config.xml is a Java
bean, stored in appropriate scope. Only instead of initializing these
beans manually Struts does it for you.

So, instead of storing stuff in action or in an action form you can
store it directly in the session or in application context. Also, read
about "servlet lifecycle" and see, maybe you better create a helper
servlet and initialize global data when servlet starts. You can set
the order in which servlets are initialized.

Tax data like yours is better be stored in application scope, not in
session scope. Session scope belongs to a client, and you probably do
not want to set different tax for every client ;)

Michael.

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

Reply via email to