You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Bender <db...@umn.edu> on 2004/09/03 03:38:02 UTC
Staying relative
I'm new to Struts and liking it so far. But I'm stumped on how I can get a user of my web application to stay in the same subdirectory throughout the workflow without going through a lot of hoops.
Here's what I mean. Our application will be used by 100 people divided into six work groups. Each group has access only to their section of the web site. And each section of the web site will have about five different functions, for example an upload a file section, an Events listing section, an bulletin board section.
The code/functionality in each section is identical from group to group, so I want to use the same set of JSPs and Actions for each group. (That re-use thing.)
To make the security managable, I've organized the site (and corresponding URLs) in a directory hierarchy like this:
/app1/areas/group1/section1
/app1/areas/group1/section2
/app1/areas/group1/section3
...
/app1/areas/group2/section1
/app1/areas/group2/section2
/app1/areas/group2/section3
...
Where I'm having trouble is staying in the same section. If a member of group1 goes to section1, and my actions are defined like this :
<action forward="input.jsp" path="input" />
that takes the user to /app1/input.do, which is outside the "section". If I change my actions to specify the absolute path for each Action, it works, but I have to create six sets of actions, one for each section, like this:
<action forward="input.jsp" path="/app1/areas/group1/section1/input" />
That works, but ... is that how I'm *supposed* to to do it? I'm just getting started and I've got a butt-load of Actions. I don't want to manage them in sextuples. That seems repetitive and error prone, along with being a maintenance headache.
Any help would be appreciated. It seems like this problem must have been solved elegantly somehow, but I'm lost as to how.
Dave
RE: Staying relative
Posted by Joe Germuska <Jo...@Germuska.com>.
At 8:22 AM -0500 9/3/04, Dave Bender wrote:
>Joe,
>
>Thanks for the reply. I'll take a look at modules this morning.
>That seems like a good solution. If I understand them correctly, I
>can create six different modules that all point to the same
>collection of actions and they'd all keep the users 'in their own
>spot.'
Hm, that's a good point. Normally each module would use a different
struts-config file, but if the files are really identical, I don't
see why you couldn't point each module to use the same file. Struts
also supports using multiple config files (additively) so you could
have each module use a shared config file and then have a
supplemental config file for the module-specific elements.
>On your second point, having different paths vs. creating a session
>variable, here's my thinking so far (I'm open to doing things
>differently; this is just how I'm coming into it as a Struts newbie):
>
>- I'm using the URLs to determine which section the user is in.
>That's what's making it critical that I have control of the URLs.
In the nightly builds, there is support for using wildcards in action
mappings. That might help. Not only can you map a pattern, but you
can use the "match groups" as parameters to the action so that each
action could know in which context it was executing. It sounds like
this is what you're doing logically anyway. In fact, as I think
about it, if you really use the same config file, then each action
probably wouldn't know under which "group" it was executing. Are you
actually analyzing the URL in the action, or just changing the config
so that each URL is slightly different and carries with it slightly
different config parameters?
Note that Struts 1.2.2 was cut a few days ago, and except for the
fact that it depends on JDK 1.4 (by accident), there's nothing wrong
with it. The binary distribution includes a wrong version of the
commons-validator jar, but you can get that from somewhere else.
Struts 1.2.3 should be cut next week correcting those two problems.
>- I thought about using a session variable, but it seems more
>unwieldy than using URLs. A detail I didn't mention in my initial
>posting is that some of the users of the site will be in more than
>one group. It's conceivable that they could jump from one section
>to another midway through a work-flow.
OK, then you have a case. Still, you could keep pushing parameters
and get the same result. Ultimately here I think you'll just have to
make a style call. It will probably take some time, and i suppose
odds are good that you'll decide you would have done it differently
by the time you're done! (I do that all the time...)
Keep us posted.
Joe
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn
back; I'll know I'm in the wrong place."
- Carlos Santana
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Staying relative
Posted by Dave Bender <db...@umn.edu>.
Joe,
Thanks for the reply. I'll take a look at modules this morning. That seems like a good solution. If I understand them correctly, I can create six different modules that all point to the same collection of actions and they'd all keep the users 'in their own spot.'
On your second point, having different paths vs. creating a session variable, here's my thinking so far (I'm open to doing things differently; this is just how I'm coming into it as a Struts newbie):
- I'm using the URLs to determine which section the user is in. That's what's making it critical that I have control of the URLs.
- I thought about using a session variable, but it seems more unwieldy than using URLs. A detail I didn't mention in my initial posting is that some of the users of the site will be in more than one group. It's conceivable that they could jump from one section to another midway through a work-flow.
If they do so and the application is watching the URLs, a switch in sections should be quick and easy to find. If I'm using a session variable, I need to pay attention to that with every request. That seems like more responsibility than I want to take on if I don't have to.
Now, on to those modules....
Dave
-----Original Message-----
From: Joe Germuska [mailto:Joe@Germuska.com]
Sent: Friday, September 03, 2004 7:52 AM
To: Struts Users Mailing List
Subject: Re: Staying relative
Dave:
One way to get Struts to rewrite action paths with more context is to
use modules; if your users really stay "within" an area, then using
Modules to partition your app will result in all Struts URL rewriting
to prepend the paths with both the servlet context path and the
module context path.
But as I'm absorbing your application design, I'm not sure I see why
you have different paths; if you want to reuse the same pages and if
the behavior is essentially the same, then why not establish a "group
identifier" in the session at user authentication time, and then just
use a single tree of behaviors in which all the code is aware that
users have group IDs and that the code's behavior is likely to be
dependent on the value of that ID.
Have I oversimplified your app? Even if you can come up with
exceptions, you still might be better off shifting the awareness of
groups into code and out of the config.
Does this help?
Joe
At 8:38 PM -0500 9/2/04, Dave Bender wrote:
>I'm new to Struts and liking it so far. But I'm stumped on how I
>can get a user of my web application to stay in the same
>subdirectory throughout the workflow without going through a lot of
>hoops.
>
>Here's what I mean. Our application will be used by 100 people
>divided into six work groups. Each group has access only to their
>section of the web site. And each section of the web site will have
>about five different functions, for example an upload a file
>section, an Events listing section, an bulletin board section.
>
>The code/functionality in each section is identical from group to
>group, so I want to use the same set of JSPs and Actions for each
>group. (That re-use thing.)
>
>To make the security managable, I've organized the site (and
>corresponding URLs) in a directory hierarchy like this:
>
>/app1/areas/group1/section1
>/app1/areas/group1/section2
>/app1/areas/group1/section3
> ...
>/app1/areas/group2/section1
>/app1/areas/group2/section2
>/app1/areas/group2/section3
> ...
>
>Where I'm having trouble is staying in the same section. If a
>member of group1 goes to section1, and my actions are defined like
>this :
>
> <action forward="input.jsp" path="input" />
>
>that takes the user to /app1/input.do, which is outside the
>"section". If I change my actions to specify the absolute path for
>each Action, it works, but I have to create six sets of actions, one
>for each section, like this:
>
> <action forward="input.jsp" path="/app1/areas/group1/section1/input" />
>
>That works, but ... is that how I'm *supposed* to to do it? I'm
>just getting started and I've got a butt-load of Actions. I don't
>want to manage them in sextuples. That seems repetitive and error
>prone, along with being a maintenance headache.
>
>Any help would be appreciated. It seems like this problem must have
>been solved elegantly somehow, but I'm lost as to how.
>
>Dave
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn
back; I'll know I'm in the wrong place."
- Carlos Santana
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Staying relative
Posted by Joe Germuska <Jo...@Germuska.com>.
Dave:
One way to get Struts to rewrite action paths with more context is to
use modules; if your users really stay "within" an area, then using
Modules to partition your app will result in all Struts URL rewriting
to prepend the paths with both the servlet context path and the
module context path.
But as I'm absorbing your application design, I'm not sure I see why
you have different paths; if you want to reuse the same pages and if
the behavior is essentially the same, then why not establish a "group
identifier" in the session at user authentication time, and then just
use a single tree of behaviors in which all the code is aware that
users have group IDs and that the code's behavior is likely to be
dependent on the value of that ID.
Have I oversimplified your app? Even if you can come up with
exceptions, you still might be better off shifting the awareness of
groups into code and out of the config.
Does this help?
Joe
At 8:38 PM -0500 9/2/04, Dave Bender wrote:
>I'm new to Struts and liking it so far. But I'm stumped on how I
>can get a user of my web application to stay in the same
>subdirectory throughout the workflow without going through a lot of
>hoops.
>
>Here's what I mean. Our application will be used by 100 people
>divided into six work groups. Each group has access only to their
>section of the web site. And each section of the web site will have
>about five different functions, for example an upload a file
>section, an Events listing section, an bulletin board section.
>
>The code/functionality in each section is identical from group to
>group, so I want to use the same set of JSPs and Actions for each
>group. (That re-use thing.)
>
>To make the security managable, I've organized the site (and
>corresponding URLs) in a directory hierarchy like this:
>
>/app1/areas/group1/section1
>/app1/areas/group1/section2
>/app1/areas/group1/section3
> ...
>/app1/areas/group2/section1
>/app1/areas/group2/section2
>/app1/areas/group2/section3
> ...
>
>Where I'm having trouble is staying in the same section. If a
>member of group1 goes to section1, and my actions are defined like
>this :
>
> <action forward="input.jsp" path="input" />
>
>that takes the user to /app1/input.do, which is outside the
>"section". If I change my actions to specify the absolute path for
>each Action, it works, but I have to create six sets of actions, one
>for each section, like this:
>
> <action forward="input.jsp" path="/app1/areas/group1/section1/input" />
>
>That works, but ... is that how I'm *supposed* to to do it? I'm
>just getting started and I've got a butt-load of Actions. I don't
>want to manage them in sextuples. That seems repetitive and error
>prone, along with being a maintenance headache.
>
>Any help would be appreciated. It seems like this problem must have
>been solved elegantly somehow, but I'm lost as to how.
>
>Dave
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn
back; I'll know I'm in the wrong place."
- Carlos Santana
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org