You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard <ri...@gmail.com> on 2004/10/13 11:13:39 UTC

sending/maintaning a download link

hi guys,

how do i do this in struts?

i want to send a download link ( via email - resolved ) to a newly
registered user and that download link will expire after 24hrs.

is there and apache project for this?

please help

thanks in advance
richard

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


Re: sending/maintaning a download link

Posted by Richard <ri...@gmail.com>.
Hello Guys,

I am about to start on this module below. I have asked this I think a
month ago and only after finishing the rest of my small website will I
implement this. Anyway im on track on learning the token creation for
struts and the quartzs plugin. I was wondering if I will be sending
the file streaming or I can just have a forward in my action mapping
that would serialized the file?

Thanks in advance
Richard


On Wed, 13 Oct 2004 10:12:38 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> The only way to make a link go away is to make it dynamic. That means that
> the link you email will have to be to an action that returns the file. There
> have been quite a few threads recently on this mailing list about how to get
> actions to return files, including .pdf and .csv, so I won't cover that
> here.
> 
> Here is a list of steps for how I would go about implementing this feature:
> 
> 1 - generate a unique token and store it in the database with a
> timestamp=now() and status=valid.
> 2 - add this token to the url you send in the email:
> http://www.mycompany.com/myapp/download.do?token=123abc
> 3 - when the user calls the action via the supplied url, the action checks
> the database to see if the token is still valid.
> 4 - if token is valid, send the file, and then invalidate the token so it
> can't be used again. (status=used)
> 5 - if token not valid, display a message to the user telling them that the
> link has either expired or already been used.
> 6 - have a background process run periodically (1 per day, every hour,
> whatever) that checks the timestamps in the database and expires tokens if
> the timestamp is more than 24 hours old. (status=expired)
> 
> The background process can be run via Quartz, which was also covered
> recently in this list.
> 
> Wiebe de Jong
> 
> 
> 
> -----Original Message-----
> From: Richard [mailto:richards.list@gmail.com]
> Sent: Wednesday, October 13, 2004 2:14 AM
> To: Struts Users Mailing List
> Subject: sending/maintaning a download link
> 
> hi guys,
> 
> how do i do this in struts?
> 
> i want to send a download link ( via email - resolved ) to a newly
> registered user and that download link will expire after 24hrs.
> 
> is there and apache project for this?
> 
> please help
> 
> thanks in advance
> richard
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


Re: sending/maintaning a download link

Posted by Richard <ri...@gmail.com>.
Thanks guys for the help.
Thanks for bringing the idea forward Craig. 


On Thu, 14 Oct 2004 11:40:49 -0700, Craig McClanahan <cr...@gmail.com> wrote:
> You should note that the standard struts-example webapp does exactly
> this ... the "database" is represented as an XML file that is
> initialzed in the init() method of a plugin, and finalized in the
> destroy() method.
> 
> Craig
> 
> 
> On Thu, 14 Oct 2004 09:43:36 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> > If you don't have access to a database, then creating some kind of in-memory
> 
> 
> > database and storing it in the servlet context is a good alternative. Use a
> > Struts plugin for setup and cleanup of whatever you use.
> >
> > One thing you will have to be careful of is using up all your memory. If you
> > are storing token/timestamp/status for a large number of users, it will add
> > up.
> >
> > Wiebe
> >
> >
> >
> > -----Original Message-----
> > From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
> > Sent: Wednesday, October 13, 2004 8:23 PM
> > To: Struts Users Mailing List
> > Subject: Re: sending/maintaning a download link
> >
> > It wouldnt survive a server restart, but this may well be acceptable if
> > you dont expect the server to restart very often and your token expiry
> > is only a day or two and its easy to get another token if needs be.
> >
> > Im not sure what the deal is with stuff added to servlet context after
> > startup in a clustered environment however. If your in a cluster you
> > would need to check up on that in the docs as it may not be available to
> > all servers in the cluster?
> >
> > Richard wrote:
> >
> > > Hi Wiebe,
> > >
> > > What if im not going to use any database? can I just store this in the
> > > servlet context?
> > >
> > > Thanks
> > > Richard
> > >
> > >
> > > On Wed, 13 Oct 2004 10:12:38 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> > >
> > >>The only way to make a link go away is to make it dynamic. That means that
> > >>the link you email will have to be to an action that returns the file.
> > There
> > >>have been quite a few threads recently on this mailing list about how to
> > get
> > >>actions to return files, including .pdf and .csv, so I won't cover that
> > >>here.
> > >>
> > >>Here is a list of steps for how I would go about implementing this
> > feature:
> > >>
> > >>1 - generate a unique token and store it in the database with a
> > >>timestamp=now() and status=valid.
> > >>2 - add this token to the url you send in the email:
> > >>http://www.mycompany.com/myapp/download.do?token=123abc
> > >>3 - when the user calls the action via the supplied url, the action checks
> > >>the database to see if the token is still valid.
> > >>4 - if token is valid, send the file, and then invalidate the token so it
> > >>can't be used again. (status=used)
> > >>5 - if token not valid, display a message to the user telling them that
> > the
> > >>link has either expired or already been used.
> > >>6 - have a background process run periodically (1 per day, every hour,
> > >>whatever) that checks the timestamps in the database and expires tokens if
> > >>the timestamp is more than 24 hours old. (status=expired)
> > >>
> > >>The background process can be run via Quartz, which was also covered
> > >>recently in this list.
> > >>
> > >>Wiebe de Jong
> > >>
> > >>
> > >>
> > >>-----Original Message-----
> > >>From: Richard [mailto:richards.list@gmail.com]
> > >>Sent: Wednesday, October 13, 2004 2:14 AM
> > >>To: Struts Users Mailing List
> > >>Subject: sending/maintaning a download link
> > >>
> > >>hi guys,
> > >>
> > >>how do i do this in struts?
> > >>
> > >>i want to send a download link ( via email - resolved ) to a newly
> > >>registered user and that download link will expire after 24hrs.
> > >>
> > >>is there and apache project for this?
> > >>
> > >>please help
> > >>
> > >>thanks in advance
> > >>richard
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >>For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >>For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


Re: sending/maintaning a download link

Posted by Craig McClanahan <cr...@gmail.com>.
You should note that the standard struts-example webapp does exactly
this ... the "database" is represented as an XML file that is
initialzed in the init() method of a plugin, and finalized in the
destroy() method.

Craig


On Thu, 14 Oct 2004 09:43:36 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> If you don't have access to a database, then creating some kind of in-memory
> database and storing it in the servlet context is a good alternative. Use a
> Struts plugin for setup and cleanup of whatever you use.
> 
> One thing you will have to be careful of is using up all your memory. If you
> are storing token/timestamp/status for a large number of users, it will add
> up.
> 
> Wiebe
> 
> 
> 
> -----Original Message-----
> From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
> Sent: Wednesday, October 13, 2004 8:23 PM
> To: Struts Users Mailing List
> Subject: Re: sending/maintaning a download link
> 
> It wouldnt survive a server restart, but this may well be acceptable if
> you dont expect the server to restart very often and your token expiry
> is only a day or two and its easy to get another token if needs be.
> 
> Im not sure what the deal is with stuff added to servlet context after
> startup in a clustered environment however. If your in a cluster you
> would need to check up on that in the docs as it may not be available to
> all servers in the cluster?
> 
> Richard wrote:
> 
> > Hi Wiebe,
> >
> > What if im not going to use any database? can I just store this in the
> > servlet context?
> >
> > Thanks
> > Richard
> >
> >
> > On Wed, 13 Oct 2004 10:12:38 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> >
> >>The only way to make a link go away is to make it dynamic. That means that
> >>the link you email will have to be to an action that returns the file.
> There
> >>have been quite a few threads recently on this mailing list about how to
> get
> >>actions to return files, including .pdf and .csv, so I won't cover that
> >>here.
> >>
> >>Here is a list of steps for how I would go about implementing this
> feature:
> >>
> >>1 - generate a unique token and store it in the database with a
> >>timestamp=now() and status=valid.
> >>2 - add this token to the url you send in the email:
> >>http://www.mycompany.com/myapp/download.do?token=123abc
> >>3 - when the user calls the action via the supplied url, the action checks
> >>the database to see if the token is still valid.
> >>4 - if token is valid, send the file, and then invalidate the token so it
> >>can't be used again. (status=used)
> >>5 - if token not valid, display a message to the user telling them that
> the
> >>link has either expired or already been used.
> >>6 - have a background process run periodically (1 per day, every hour,
> >>whatever) that checks the timestamps in the database and expires tokens if
> >>the timestamp is more than 24 hours old. (status=expired)
> >>
> >>The background process can be run via Quartz, which was also covered
> >>recently in this list.
> >>
> >>Wiebe de Jong
> >>
> >>
> >>
> >>-----Original Message-----
> >>From: Richard [mailto:richards.list@gmail.com]
> >>Sent: Wednesday, October 13, 2004 2:14 AM
> >>To: Struts Users Mailing List
> >>Subject: sending/maintaning a download link
> >>
> >>hi guys,
> >>
> >>how do i do this in struts?
> >>
> >>i want to send a download link ( via email - resolved ) to a newly
> >>registered user and that download link will expire after 24hrs.
> >>
> >>is there and apache project for this?
> >>
> >>please help
> >>
> >>thanks in advance
> >>richard
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


Re: sending/maintaning a download link

Posted by Richard <ri...@gmail.com>.
thanks.


On Thu, 14 Oct 2004 11:22:58 +0800, Andrew Hill
<an...@gridnode.com> wrote:
> It wouldnt survive a server restart, but this may well be acceptable if
> you dont expect the server to restart very often and your token expiry
> is only a day or two and its easy to get another token if needs be.
> 
> Im not sure what the deal is with stuff added to servlet context after
> startup in a clustered environment however. If your in a cluster you
> would need to check up on that in the docs as it may not be available to
> all servers in the cluster?
> 
> 
> 
> Richard wrote:
> 
> > Hi Wiebe,
> >
> > What if im not going to use any database? can I just store this in the
> > servlet context?
> >
> > Thanks
> > Richard
> >
> >
> > On Wed, 13 Oct 2004 10:12:38 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> >
> >>The only way to make a link go away is to make it dynamic. That means that
> >>the link you email will have to be to an action that returns the file. There
> >>have been quite a few threads recently on this mailing list about how to get
> >>actions to return files, including .pdf and .csv, so I won't cover that
> >>here.
> >>
> >>Here is a list of steps for how I would go about implementing this feature:
> >>
> >>1 - generate a unique token and store it in the database with a
> >>timestamp=now() and status=valid.
> >>2 - add this token to the url you send in the email:
> >>http://www.mycompany.com/myapp/download.do?token=123abc
> >>3 - when the user calls the action via the supplied url, the action checks
> >>the database to see if the token is still valid.
> >>4 - if token is valid, send the file, and then invalidate the token so it
> >>can't be used again. (status=used)
> >>5 - if token not valid, display a message to the user telling them that the
> >>link has either expired or already been used.
> >>6 - have a background process run periodically (1 per day, every hour,
> >>whatever) that checks the timestamps in the database and expires tokens if
> >>the timestamp is more than 24 hours old. (status=expired)
> >>
> >>The background process can be run via Quartz, which was also covered
> >>recently in this list.
> >>
> >>Wiebe de Jong
> >>
> >>
> >>
> >>-----Original Message-----
> >>From: Richard [mailto:richards.list@gmail.com]
> >>Sent: Wednesday, October 13, 2004 2:14 AM
> >>To: Struts Users Mailing List
> >>Subject: sending/maintaning a download link
> >>
> >>hi guys,
> >>
> >>how do i do this in struts?
> >>
> >>i want to send a download link ( via email - resolved ) to a newly
> >>registered user and that download link will expire after 24hrs.
> >>
> >>is there and apache project for this?
> >>
> >>please help
> >>
> >>thanks in advance
> >>richard
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> > 
> > ---------------------------------------------------------------------
> 
> 
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


RE: sending/maintaning a download link

Posted by Wiebe de Jong <wi...@shaw.ca>.
If you don't have access to a database, then creating some kind of in-memory
database and storing it in the servlet context is a good alternative. Use a
Struts plugin for setup and cleanup of whatever you use.

One thing you will have to be careful of is using up all your memory. If you
are storing token/timestamp/status for a large number of users, it will add
up.

Wiebe

-----Original Message-----
From: Andrew Hill [mailto:andrew.david.hill@gridnode.com] 
Sent: Wednesday, October 13, 2004 8:23 PM
To: Struts Users Mailing List
Subject: Re: sending/maintaning a download link

It wouldnt survive a server restart, but this may well be acceptable if 
you dont expect the server to restart very often and your token expiry 
is only a day or two and its easy to get another token if needs be.

Im not sure what the deal is with stuff added to servlet context after 
startup in a clustered environment however. If your in a cluster you 
would need to check up on that in the docs as it may not be available to 
all servers in the cluster?

Richard wrote:

> Hi Wiebe,
> 
> What if im not going to use any database? can I just store this in the
> servlet context?
> 
> Thanks
> Richard
> 
> 
> On Wed, 13 Oct 2004 10:12:38 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> 
>>The only way to make a link go away is to make it dynamic. That means that
>>the link you email will have to be to an action that returns the file.
There
>>have been quite a few threads recently on this mailing list about how to
get
>>actions to return files, including .pdf and .csv, so I won't cover that
>>here.
>>
>>Here is a list of steps for how I would go about implementing this
feature:
>>
>>1 - generate a unique token and store it in the database with a
>>timestamp=now() and status=valid.
>>2 - add this token to the url you send in the email:
>>http://www.mycompany.com/myapp/download.do?token=123abc
>>3 - when the user calls the action via the supplied url, the action checks
>>the database to see if the token is still valid.
>>4 - if token is valid, send the file, and then invalidate the token so it
>>can't be used again. (status=used)
>>5 - if token not valid, display a message to the user telling them that
the
>>link has either expired or already been used.
>>6 - have a background process run periodically (1 per day, every hour,
>>whatever) that checks the timestamps in the database and expires tokens if
>>the timestamp is more than 24 hours old. (status=expired)
>>
>>The background process can be run via Quartz, which was also covered
>>recently in this list.
>>
>>Wiebe de Jong
>>
>>
>>
>>-----Original Message-----
>>From: Richard [mailto:richards.list@gmail.com]
>>Sent: Wednesday, October 13, 2004 2:14 AM
>>To: Struts Users Mailing List
>>Subject: sending/maintaning a download link
>>
>>hi guys,
>>
>>how do i do this in struts?
>>
>>i want to send a download link ( via email - resolved ) to a newly
>>registered user and that download link will expire after 24hrs.
>>
>>is there and apache project for this?
>>
>>please help
>>
>>thanks in advance
>>richard
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


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


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


Re: sending/maintaning a download link

Posted by Andrew Hill <an...@gridnode.com>.
It wouldnt survive a server restart, but this may well be acceptable if 
you dont expect the server to restart very often and your token expiry 
is only a day or two and its easy to get another token if needs be.

Im not sure what the deal is with stuff added to servlet context after 
startup in a clustered environment however. If your in a cluster you 
would need to check up on that in the docs as it may not be available to 
all servers in the cluster?

Richard wrote:

> Hi Wiebe,
> 
> What if im not going to use any database? can I just store this in the
> servlet context?
> 
> Thanks
> Richard
> 
> 
> On Wed, 13 Oct 2004 10:12:38 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> 
>>The only way to make a link go away is to make it dynamic. That means that
>>the link you email will have to be to an action that returns the file. There
>>have been quite a few threads recently on this mailing list about how to get
>>actions to return files, including .pdf and .csv, so I won't cover that
>>here.
>>
>>Here is a list of steps for how I would go about implementing this feature:
>>
>>1 - generate a unique token and store it in the database with a
>>timestamp=now() and status=valid.
>>2 - add this token to the url you send in the email:
>>http://www.mycompany.com/myapp/download.do?token=123abc
>>3 - when the user calls the action via the supplied url, the action checks
>>the database to see if the token is still valid.
>>4 - if token is valid, send the file, and then invalidate the token so it
>>can't be used again. (status=used)
>>5 - if token not valid, display a message to the user telling them that the
>>link has either expired or already been used.
>>6 - have a background process run periodically (1 per day, every hour,
>>whatever) that checks the timestamps in the database and expires tokens if
>>the timestamp is more than 24 hours old. (status=expired)
>>
>>The background process can be run via Quartz, which was also covered
>>recently in this list.
>>
>>Wiebe de Jong
>>
>>
>>
>>-----Original Message-----
>>From: Richard [mailto:richards.list@gmail.com]
>>Sent: Wednesday, October 13, 2004 2:14 AM
>>To: Struts Users Mailing List
>>Subject: sending/maintaning a download link
>>
>>hi guys,
>>
>>how do i do this in struts?
>>
>>i want to send a download link ( via email - resolved ) to a newly
>>registered user and that download link will expire after 24hrs.
>>
>>is there and apache project for this?
>>
>>please help
>>
>>thanks in advance
>>richard
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


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


Re: sending/maintaning a download link

Posted by Richard <ri...@gmail.com>.
Hi Wiebe,

What if im not going to use any database? can I just store this in the
servlet context?

Thanks
Richard


On Wed, 13 Oct 2004 10:12:38 -0700, Wiebe de Jong <wi...@shaw.ca> wrote:
> The only way to make a link go away is to make it dynamic. That means that
> the link you email will have to be to an action that returns the file. There
> have been quite a few threads recently on this mailing list about how to get
> actions to return files, including .pdf and .csv, so I won't cover that
> here.
> 
> Here is a list of steps for how I would go about implementing this feature:
> 
> 1 - generate a unique token and store it in the database with a
> timestamp=now() and status=valid.
> 2 - add this token to the url you send in the email:
> http://www.mycompany.com/myapp/download.do?token=123abc
> 3 - when the user calls the action via the supplied url, the action checks
> the database to see if the token is still valid.
> 4 - if token is valid, send the file, and then invalidate the token so it
> can't be used again. (status=used)
> 5 - if token not valid, display a message to the user telling them that the
> link has either expired or already been used.
> 6 - have a background process run periodically (1 per day, every hour,
> whatever) that checks the timestamps in the database and expires tokens if
> the timestamp is more than 24 hours old. (status=expired)
> 
> The background process can be run via Quartz, which was also covered
> recently in this list.
> 
> Wiebe de Jong
> 
> 
> 
> -----Original Message-----
> From: Richard [mailto:richards.list@gmail.com]
> Sent: Wednesday, October 13, 2004 2:14 AM
> To: Struts Users Mailing List
> Subject: sending/maintaning a download link
> 
> hi guys,
> 
> how do i do this in struts?
> 
> i want to send a download link ( via email - resolved ) to a newly
> registered user and that download link will expire after 24hrs.
> 
> is there and apache project for this?
> 
> please help
> 
> thanks in advance
> richard
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


RE: sending/maintaning a download link

Posted by Wiebe de Jong <wi...@shaw.ca>.
The only way to make a link go away is to make it dynamic. That means that
the link you email will have to be to an action that returns the file. There
have been quite a few threads recently on this mailing list about how to get
actions to return files, including .pdf and .csv, so I won't cover that
here.

Here is a list of steps for how I would go about implementing this feature:

1 - generate a unique token and store it in the database with a
timestamp=now() and status=valid.
2 - add this token to the url you send in the email:
http://www.mycompany.com/myapp/download.do?token=123abc
3 - when the user calls the action via the supplied url, the action checks
the database to see if the token is still valid.
4 - if token is valid, send the file, and then invalidate the token so it
can't be used again. (status=used)
5 - if token not valid, display a message to the user telling them that the
link has either expired or already been used.
6 - have a background process run periodically (1 per day, every hour,
whatever) that checks the timestamps in the database and expires tokens if
the timestamp is more than 24 hours old. (status=expired)

The background process can be run via Quartz, which was also covered
recently in this list.

Wiebe de Jong

-----Original Message-----
From: Richard [mailto:richards.list@gmail.com] 
Sent: Wednesday, October 13, 2004 2:14 AM
To: Struts Users Mailing List
Subject: sending/maintaning a download link

hi guys,

how do i do this in struts?

i want to send a download link ( via email - resolved ) to a newly
registered user and that download link will expire after 24hrs.

is there and apache project for this?

please help

thanks in advance
richard

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


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