You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Woodchuck <wo...@yahoo.com> on 2004/09/09 20:29:50 UTC

can i get ".do" from struts?

hihi,

does struts have a built-in way to get the literal ".do" (or whichever
extension URL ending pattern you specify) string?

or put another way, can anyone suggest an elegant way to forward to
another action?

ie. when creating an ActionForward object, it needs "/myAction.do"
instead of "/myAction"...

i don't want to hard-code any struts-config information in my code per
se, so what i'm doing is getting the desired ActionConfig based on my
Action class's fqn. and then interrogating the object for the path
value which gives me "/myAction", but i need to append the stripped
away URL ending pattern (in my case ".do").

anyone have elegant solutions for this?

please and thanks,
woodchuck




		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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


Re: can i get ".do" from struts?

Posted by Woodchuck <wo...@yahoo.com>.
--- Rick Reumann <st...@reumann.net> wrote:

> Woodchuck said the following on 9/9/2004 2:29 PM:
> 
> > i don't want to hard-code any struts-config information in my code
> per
> > se, so what i'm doing is getting the desired ActionConfig based on
> my
> > Action class's fqn. and then interrogating the object for the path
> > value which gives me "/myAction", but i need to append the stripped
> > away URL ending pattern (in my case ".do").
> > 
> > anyone have elegant solutions for this?
> 
> Taking a quick look at the form tag source code it looks like that 
> mapping is placed in scope under the Globals.SERVLET_KEY key. So if
> you 
> wanted I guess you could get it out like...
> 
> ${applicationScope["org.apache.struts.action.SERVLET_MAPPING"]}
>

thanks Rick!  in my Action class i have to do this:

this.getServlet().getServletContext().getAttribute(Globals.SERVLET_KEY)

and it returns "*.do"

 
> I still don't see why you'd really need to do this though. Couldn't
> you 
> just make the mapping something like /app/* or /control/* something
> VERY 
> generic. If it's so generic I don't think you'd ever need to change
> it. 
> You could even make it /a/* or whatever.

very true.


> 
> -- 
> Rick
> 



		
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 

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


Re: can i get ".do" from struts?

Posted by Rick Reumann <st...@reumann.net>.
Woodchuck said the following on 9/9/2004 2:29 PM:

> i don't want to hard-code any struts-config information in my code per
> se, so what i'm doing is getting the desired ActionConfig based on my
> Action class's fqn. and then interrogating the object for the path
> value which gives me "/myAction", but i need to append the stripped
> away URL ending pattern (in my case ".do").
> 
> anyone have elegant solutions for this?

Taking a quick look at the form tag source code it looks like that 
mapping is placed in scope under the Globals.SERVLET_KEY key. So if you 
wanted I guess you could get it out like...

${applicationScope["org.apache.struts.action.SERVLET_MAPPING"]}

I still don't see why you'd really need to do this though. Couldn't you 
just make the mapping something like /app/* or /control/* something VERY 
generic. If it's so generic I don't think you'd ever need to change it. 
You could even make it /a/* or whatever.

-- 
Rick

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


Re: can i get ".do" from struts?

Posted by Woodchuck <wo...@yahoo.com>.
--- Bill Siggelkow <bi...@bellsouth.net> wrote:

> Why don't you use global forwards defined in your struts-config.xml. 
> Essentially creating a logical URL referencable by name. You can even
> 
> have a query string in the forward's path.
> 
> In your struts-config.xml:
> <foward name="gotoFoo" path="/Foo.do"/>
> 
> On a JSP page:
> <html:link forward="gotoFoo">Goto Foo</html:link>
> 
> Or in an action:
> return mapping.findForward("gotoFoo");

hi Bill, thanks for your excellent suggestions!  global forwards will
work nicely as well.  however, i've already designated global forwards
only for the main menus in my web app, and adding other non-main
forwards there will break my convention.  otherwise it's definitely
another good possiblity!


> 
> Woodchuck wrote:
> 
> > hihi,
> > 
> > does struts have a built-in way to get the literal ".do" (or
> whichever
> > extension URL ending pattern you specify) string?
> > 
> > or put another way, can anyone suggest an elegant way to forward to
> > another action?
> > 
> > ie. when creating an ActionForward object, it needs "/myAction.do"
> > instead of "/myAction"...
> > 
> > i don't want to hard-code any struts-config information in my code
> per
> > se, so what i'm doing is getting the desired ActionConfig based on
> my
> > Action class's fqn. and then interrogating the object for the path
> > value which gives me "/myAction", but i need to append the stripped
> > away URL ending pattern (in my case ".do").
> > 
> > anyone have elegant solutions for this?
> > 
> > please and thanks,
> > woodchuck
> > 
> > 
> > 
> > 
> > 		
> > __________________________________
> > Do you Yahoo!?
> > New and Improved Yahoo! Mail - Send 10MB messages!
> > http://promotions.yahoo.com/new_mail 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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


Re: can i get ".do" from struts?

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Why don't you use global forwards defined in your struts-config.xml. 
Essentially creating a logical URL referencable by name. You can even 
have a query string in the forward's path.

In your struts-config.xml:
<foward name="gotoFoo" path="/Foo.do"/>

On a JSP page:
<html:link forward="gotoFoo">Goto Foo</html:link>

Or in an action:
return mapping.findForward("gotoFoo");

Woodchuck wrote:

> hihi,
> 
> does struts have a built-in way to get the literal ".do" (or whichever
> extension URL ending pattern you specify) string?
> 
> or put another way, can anyone suggest an elegant way to forward to
> another action?
> 
> ie. when creating an ActionForward object, it needs "/myAction.do"
> instead of "/myAction"...
> 
> i don't want to hard-code any struts-config information in my code per
> se, so what i'm doing is getting the desired ActionConfig based on my
> Action class's fqn. and then interrogating the object for the path
> value which gives me "/myAction", but i need to append the stripped
> away URL ending pattern (in my case ".do").
> 
> anyone have elegant solutions for this?
> 
> please and thanks,
> woodchuck
> 
> 
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
> http://promotions.yahoo.com/new_mail 


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