You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lis <li...@ukrindustrial.com> on 2003/11/28 16:21:20 UTC

Where I can perform global tasks for application ?

Hello

Where I can perform global tasks for application ?
I mean: some user specific configure tasks for example or check for
user is signin in.

I do it via Filter Servlet now,
but I think exists other method on the MVC framework for this job.

In other words, how I can add some task, which Struts controller will
perform for me for every http request.

-- 
Best regards,
 lis


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Is there a way to not append jessionid with html:rewrite

Posted by Joshua Long <St...@adelphia.net>.
Hi all, 

Is there a way to use html:rewrite and not have it embed the jsessionid
on certain links (as with JavaScripts, images, or css style sheets which
don't really work well with resources that have arbitrary strings
attached to them -- that is, here's the issue:

<script language="JavaScript" src="<html:rewrite forward="image_dir"
/>Pagination.js"> </script> 

This yields, as the page is loaded,
/site/assets/js/?jsessionid32543543Pagination.js or some such string --
I could create forwards for every image, js and css in the site and then
have the forward just write <html:rewrite forward=pagination_js /> but
that seems awfully hackish and clunky and just moves the bad design to
the struts-cohnfig.xml, which I imagine is where it should be ifg
anywhere but still, theres got to be a better way? A tag attribute, a
page scope attribute, something. 

Any help is again appreciated, thanks, 

Josh


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Where I can perform global tasks for application ?

Posted by Ted Husted <hu...@apache.org>.
There's nothing wrong with using a filter, if that works for you.

Within the Struts framework, you can either extend the RequestProcessor 
or use a base Action.

Extending the RequestProcessor ensures that the task will be performed 
for each request, but some developers shy away from extending the 
RequestProcessor.

With a base Action, you are not guaranteed that the task will be 
performed unless each Action you use extends the base Action. The usual 
approach is to define your own version of the execute signature and mark 
it abstract. You then put whatever you need to do each time in the base 
execute signature and that one call your version when it's ready.

ActionForward myExecute(...) throws ...;

ActionForward execute(...) throws ... {

	ActionForward forward = doMyStuff(...);

	if (forward!=null) return forward;

	return execute(...);

}

For access and authorization checks, a good approach is to use JAAS and 
the processRoles property of the ActionMapping. Alternatively, you can 
extend the RequestProcessor to handle your own login code.

HTH, Ted.

lis wrote:
> Hello
> 
> Where I can perform global tasks for application ?
> I mean: some user specific configure tasks for example or check for
> user is signin in.
> 
> I do it via Filter Servlet now,
> but I think exists other method on the MVC framework for this job.
> 
> In other words, how I can add some task, which Struts controller will
> perform for me for every http request.
> 

-- 
Ted Husted,
   Junit in Action  - <http://www.manning.com/massol/>,
   Struts in Action - <http://husted.com/struts/book.html>,
   JSP Site Design  - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org