You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dan Allen <da...@mojavelinux.com> on 2003/04/24 06:44:16 UTC

sending URLs in an email

I am setting up a brief forgot password routine for my application.
I need to be able to send the user a link back to the site with a
query string.  Aside from putting the base of the url in my
application.resources file, how would I create this url in my
Action?  RequestUtils has several methods to compute a URL, but it
seems to require pageContext to do so.  Has anyone else been down
this road and paved a solution?

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
There is no such thing as a casual knowledge of xslt, either 
you know everything about it or you are sitting in the creek.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


Re: sending URLs in an email

Posted by Dan Allen <da...@mojavelinux.com>.
Dan Allen (dan@mojavelinux.com) wrote:

> I am setting up a brief forgot password routine for my application.
> I need to be able to send the user a link back to the site with a
> query string.  Aside from putting the base of the url in my
> application.resources file, how would I create this url in my
> Action?  RequestUtils has several methods to compute a URL, but it
> seems to require pageContext to do so.  Has anyone else been down
> this road and paved a solution?
> 
> Dan

I found a solution for this.  If you think about it, the best place
to store the url is in the action mapping (since all other urls are
stored here relating to an action).  Then in the action you just
use:

String emailLink = RequestUtils.printableURL(RequestUtils.absoluteURL(request, RequestUtils.forwardURL(request, mapping.findForward("emailLink")))) + paramsOfChoice;

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Real programmers don't change their wardrobe too often: there 
are no clothes stores that are open at two o'clock in the morning. 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


StrutsMenu problem on Jboss3.0/Tomcat1.4.x

Posted by Dimitar Georgievski <di...@websyn.com>.
hi,

I'm trying to configure Struts-menu 1.2 on one Struts application running on
JBoss/tomcat. When I run the application I receieve the following error:

    org.apache.jasper.JasperException: The menu repository could not be
found.

The same thing happened with the struts-menu example application that comes
with the donwloaded code. However when I run the example on standalone
Tomcat the error does not appear.

Any idea what could be the problem?

thanks,

dimitar


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


Re: sending URLs in an email

Posted by Dan Allen <da...@mojavelinux.com>.
Craig R. McClanahan (craigmcc@apache.org) wrote:

> 
> 
> On Wed, 23 Apr 2003, Dan Allen wrote:
> 
> > Date: Wed, 23 Apr 2003 23:44:16 -0500
> > From: Dan Allen <da...@mojavelinux.com>
> > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> > To: Struts-User List <st...@jakarta.apache.org>
> > Subject: sending URLs in an email
> >
> > I am setting up a brief forgot password routine for my application.
> > I need to be able to send the user a link back to the site with a
> > query string.  Aside from putting the base of the url in my
> > application.resources file, how would I create this url in my
> > Action?  RequestUtils has several methods to compute a URL, but it
> > seems to require pageContext to do so.  Has anyone else been down
> > this road and paved a solution?
> >
> 
> If you need to do this in code (in your Action), you can assemble the
> absolute URL dynamically, without any need to store it in a config file,
> simply based on the results of the following method calls against
> HttpServletRequest:
> 
>   getScheme() --> "http" or "https"
>   getServerName() --> hostname
>   getServerPort() --> typically 80 (http) or 443 (https),
>                       should be included if it is non-default
>   getContextPath() --> first portion of the server-relative URL
> 
> The rest of the URL should be whatever context-relative path you need to
> direct people to.

Exactly, but my point was that I didn't want to "hard-code" the
action mapping path into the action itself, just in case it needed
to be changed by the JSP developer.  This is why I thought of making
a local forward to the action, and name it something appropriate lik
emailLink.  Then in my action I can just use
mapping.findForward("emailLink") and then use what you have above or
the RequestUtils forwardURL to contruct the actual URl for that
forward.  To me it seems like the perfect solution.

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
'One Microsoft Way' is more than just an address.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


Re: sending URLs in an email

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 23 Apr 2003, Dan Allen wrote:

> Date: Wed, 23 Apr 2003 23:44:16 -0500
> From: Dan Allen <da...@mojavelinux.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts-User List <st...@jakarta.apache.org>
> Subject: sending URLs in an email
>
> I am setting up a brief forgot password routine for my application.
> I need to be able to send the user a link back to the site with a
> query string.  Aside from putting the base of the url in my
> application.resources file, how would I create this url in my
> Action?  RequestUtils has several methods to compute a URL, but it
> seems to require pageContext to do so.  Has anyone else been down
> this road and paved a solution?
>

If you need to do this in code (in your Action), you can assemble the
absolute URL dynamically, without any need to store it in a config file,
simply based on the results of the following method calls against
HttpServletRequest:

  getScheme() --> "http" or "https"
  getServerName() --> hostname
  getServerPort() --> typically 80 (http) or 443 (https),
                      should be included if it is non-default
  getContextPath() --> first portion of the server-relative URL

The rest of the URL should be whatever context-relative path you need to
direct people to.

> Dan

Craig

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


Re: sending URLs in an email

Posted by Dan Allen <da...@mojavelinux.com>.
Ian Hunter (ihunter@hunterweb.net) wrote:

> I think if you the struts tags to build a URL, you're going to wind up
> potentially encoding the sessionid, which you don't want to do.  Watch out
> for that...

Yep, the solution I sent works strickly with the base url and not
with any query params or url rewriting.  It is 3 method calls and I
would like to reduce it, but it will work for now...

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
"If you are going to play the game of trial and error, 
don't be surprised when the results are revealing. -- me"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


Re: sending URLs in an email

Posted by Ian Hunter <ih...@hunterweb.net>.
I think if you the struts tags to build a URL, you're going to wind up
potentially encoding the sessionid, which you don't want to do.  Watch out
for that...

----- Original Message -----
From: "Dan Allen" <da...@mojavelinux.com>
To: "Struts-User List" <st...@jakarta.apache.org>
Sent: Thursday, April 24, 2003 12:44 AM
Subject: sending URLs in an email


> I am setting up a brief forgot password routine for my application.
> I need to be able to send the user a link back to the site with a
> query string.  Aside from putting the base of the url in my
> application.resources file, how would I create this url in my
> Action?  RequestUtils has several methods to compute a URL, but it
> seems to require pageContext to do so.  Has anyone else been down
> this road and paved a solution?
>
> Dan
>
> --
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Daniel Allen, <da...@mojavelinux.com>
> http://www.mojavelinux.com/
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> There is no such thing as a casual knowledge of xslt, either
> you know everything about it or you are sitting in the creek.
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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