You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by James Ward <ja...@firstlink.com> on 2002/06/04 08:10:49 UTC

Architecture Issue

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?

Thanks for your help.

-James

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Architecture Issue

Posted by Joe Germuska <Jo...@Germuska.com>.
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:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


-- 
--
* Joe Germuska    { joe@germuska.com }
"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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Architecture Issue

Posted by Joe Germuska <Jo...@Germuska.com>.
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:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


-- 
--
* Joe Germuska    { joe@germuska.com }
"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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Architecture Issue

Posted by Dror Matalon <dr...@zapatec.com>.
I'm no struts expert, but sounds like your problem  is a good candidate
for a filter.

There's a good article with some code about filters at 
http://www.servlets.com/soapbox/filters.html

I'm curious to see what solution "real strutters" recommend :-).

Dror

On Tue, Jun 04, 2002 at 12:10:49AM -0600, 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?
> 
> Thanks for your help.
> 
> -James
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 

-- 

Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Passing Dynamic values to tags

Posted by Nicolas De Loof <ni...@cgey.com>.
Your taglib definition file (tld) can declare an <rtexprvalue> element for
attributes of your tags. "true" value allows JSP to use "runtime expression
values".

<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

Nico




> Hi All,
>
> When I use tags in Apache tag libraries in my JSPs, I am able to pass
> dynamic values from Java as its attributes.
> Ex - <lib: form form name = <%=formname%>
>
> However when I write my own tags, I can only pass constant attibutes as
the
> tag replaces the attribute vales as as a string instead of treating it as
> Java code that needs to be executed. Any clues what I need to do to make
my
> tags accept dynamic values? or rather what has Apache done so that it
takes
> it?
>
> Thanks in advance.
>
> Regards,
> Praveer
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Passing Dynamic values to tags

Posted by Dejan Bosanac <de...@datagate.co.uk>.
You need to modify your Tag library descriptor and put
<rtexprvalue>true</rtexprvalue> inside <attribute></attribute> tags for
attributes that needs to be dynamically assigned.
--
Best regards,
Dejan Bosanac, Software Developer
DataGate Network Solutions Ltd. - http://www.datagate.net
Tel: +44 8700 119090, Fax: +44 8700 119080

----- Original Message -----
From: "Praveer Mathur" <pr...@delhi.tcs.co.in>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Tuesday, June 04, 2002 11:00 AM
Subject: Passing Dynamic values to tags


> Hi All,
>
> When I use tags in Apache tag libraries in my JSPs, I am able to pass
> dynamic values from Java as its attributes.
> Ex - <lib: form form name = <%=formname%>
>
> However when I write my own tags, I can only pass constant attibutes as
the
> tag replaces the attribute vales as as a string instead of treating it as
> Java code that needs to be executed. Any clues what I need to do to make
my
> tags accept dynamic values? or rather what has Apache done so that it
takes
> it?
>
> Thanks in advance.
>
> Regards,
> Praveer
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Passing Dynamic values to tags

Posted by Praveer Mathur <pr...@delhi.tcs.co.in>.
Hi All,

When I use tags in Apache tag libraries in my JSPs, I am able to pass
dynamic values from Java as its attributes.
Ex - <lib: form form name = <%=formname%>

However when I write my own tags, I can only pass constant attibutes as the
tag replaces the attribute vales as as a string instead of treating it as
Java code that needs to be executed. Any clues what I need to do to make my
tags accept dynamic values? or rather what has Apache done so that it takes
it?

Thanks in advance.

Regards,
Praveer


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Architecture Issue

Posted by "Grandin J. Hammell" <gr...@gsolve.com>.
I'm fairly new to Struts but my first instinct on this one is just to 
extend the ActionServlet and add the custom code you listed below.

-Grandin

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?
>
>Thanks for your help.
>
>-James
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Architecture Issue

Posted by Ted Husted <hu...@apache.org>.
For this particular use-case, I'd suggest reducing the scriptlet to a
custom tag. This would give you the ability to customize it later if
your needs change and avoid cut-and-paste reuse through the site. But
that's not going to require the use of Struts in any way. 

Model 2 and MVC are about designing dynamic Web applications that
collect and return data customized to each user. Not every Web site
needs to be dynamic or an application. 

Given this use case, I'd say you have some pages with dynamic elements
but not a web application, so Model 2 and the rest of it doesn't apply. 

Of course, there are many large static sites that can benefit from a
navigational controller to manage the links between its pages. But that
is not what was presented here.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


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?
> 
> Thanks for your help.
> 
> -James
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Architecture Issue

Posted by Robert Taylor <rt...@mulework.com>.
James,

I am working with a medium size application which contains both
static and non-static content. I'm integrating Struts and find
that my particular situation doesn't warrent using Struts for
static content.

I would suggest using a Filter to perform the
necessary logic before processing each request and map the filter
to the appropriate URL.

Later, if you wanted to go completely with a Struts solution, you
could implement the logic in the processPreprocess() in the
RequestProcessor(),
or move it farther down the chain into a base Action class.

HTH,

robert



> -----Original Message-----
> From: James Ward [mailto:jamesw@firstlink.com]
> Sent: Tuesday, June 04, 2002 2:11 AM
> To: struts-dev@jakarta.apache.org; struts-user@jakarta.apache.org
> Subject: Architecture Issue
>
>
> 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?
>
> Thanks for your help.
>
> -James
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>