At 12:10 AM -0600 2002/06/04, James Ward wrote: >Ok, I must admit that I love Struts! Who doesn't? But I have a design >dilemma. Let's suppose that I have a simple, almost static web site. >Except that on the header of each page I read the url and I am coming >from and pull some info based on that url, from a database... Simple >right? Now wouldn't MVC suggest that any request to my site that needs >something from the model go through a controller? So if I put a >controller in front of all of my pages, I either get weird url's that >don't play nice with search engines (And aren't very pretty) like: >http://mysite.com/Main.do?page=index.jsp >http://mysite.com/Main.do?page=AboutUs.jsp >Or I have to create struts actions for each page: >http://mysite.com/Index.do >http://mysite.com/AboutUs.do > >Neither of these seems ideal... So I thought I would ask the experts. > >What do you all think? Is this a place where I can stray from MVC and >do something like: ><% >String url = request.getHeader("host"); >url = url.toLowerCase(); >url = url.substring(0,url.indexOf(".")); >MemberTO myMember = new MemberBean().getMember(url); >%> > >Or, is there a much better way to do this?
If you have any expectation that the site is going to get more complicated, your second option is really pretty good. By having unique URLs for each conceptual page, you keep open the possibility of changing the behavior for preparing and displaying that page with little impact on the rest of the site. (Basically the "Link only to Actions" principle from Ted Husted's catalog of Struts best practices and strategies <http://husted.com/about/scaffolding/catalog.htm>) For now, you can have a single Action class which always does the same database work, puts the same beans into scope, and calls a local forward with a consistent name. Make sense? Joe >Thanks for your help. > >-James > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- -- * Joe Germuska { [EMAIL PROTECTED] } "It's pitiful, sometimes, if they've got it bad. Their eyes get glazed, they go white, their hands tremble.... As I watch them I often feel that a dope peddler is a gentleman compared with the man who sells records." --Sam Goody, 1956 tune in posse radio: <http://www.live365.com/stations/289268> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>