You can use a bean as a flag "this user has allready been count". Let's call
it "user".

Your welcome page should be a struts URL (welcome.do). Corresponding
WelcomeAction would look for "user" in session.

If not found, it does increment user counter, create user bean and put it in
session, so that next request from this user would not increase counter.

It looks for another bean called "counter" in application scope, and creates
it if needed. "counter" has a "hit" property. WelcomeAction set it to
current counter value. (Notice you should include synchronisation in "hit"
setter if exact counter is needed)

Then, you have to configure struts so that welcome.do forwards to your
"welcome-servlet".

Your welcome JSP just has to get "counter" from application scope and
display "hit" property. As WelcomeAction overwrite "hit" value for every new
user, your counter will be always up to date.




Hope it will help you

Nico.

> Im new to struts. I have been reading struts in action, and Im
> trying to develop my first web app. My application is currently
> quite simple. I have a welcome which I would like to incorporate
> a counter on this page. To keep tabs of the # of people who have
> hit my site. I have a servlet which needs to be called when the page
> is first visited. My question is where do I call this servlet?
> I know i need to use the <logic present tags to verify if the bean is
> present; and
> I need to call an Action class which in turn will call a bean which will
> connect to a database which will keep count of the hits.  Can the
> actionServlet
> directly call an Action since I have no need to call an ActionForm?
>  And I was under the impresion that an Action would need
> to call an ActionForward when it completes its tasks. Would i still need
to
> do this
> if the client remains on the same page?
> Thank you all for your time
>
>
****************************************************************************
****************************************************************************
*********************************
>
> This message is intended for the use of the individual or entity to which
> it is addressed and may contain information that is confidential and
> privileged and exempt from disclosure under applicable law.  If the reader
> of this message is not the intended recipient, you are hereby notified
that
> any dissemination, distribution, or copying of this communication is
> strictly prohibited.  If you have received this communication in error,
> please contact the sender immediately and delete it from your system.
> Thank you
>
****************************************************************************
****************************************************************************
*********************************
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


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

Reply via email to