• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

jsp how to keep a link only available for a certain time

Hello experts,

I have a link e.g. http://mysite/active.jsp?id=abc, when user click this link, it will active a boolean field in a table. How could make this link only available for a while, e.g. 10 minutes.

Thanks for your help.
0
lilyyan
Asked:
lilyyan
  • 4
  • 3
  • 2
1 Solution
 
KuldeepchaturvediCommented:
well you can use meta refresh tag for it

<META HTTP-EQUIV="Refresh"
CONTENT="300; URL=http://www.yoursite.com/some/place/?link=no">

this will enable your page to get refreshed in 300 seconds.
in your jsp you can check for parameter link..
<%
String link=request.getParameter("link)
if("no".equals(link)
{
// do not put the link on the screen
//also do not put the meta part in the screen
}
else
{
//put link on the screen and put meta part as well
}
}

0
 
bloodredsunCommented:
>>How could make this link only available for a while, e.g. 10 minutes.

Put somehting in the session that logs the first time, and then invalidate or don't show the link if the time is more than 10 minutes. I wouldn't use the db for this unless the link is for one time only
0
 
lilyyanAuthor Commented:
Thanks for your reply.

I'm thinking using jsp session. My application context is:

1. user input password and name in html form
2. then the info. is submitted to a register.jsp
   in this page, it will send a link:   http://mysite/active.jsp?id=abc to the user abc by email
3. when user check email, this user need click http://mysite/active.jsp?id=abc  to active his/her account.
4. I hope this link only available for a certain time, e.g. 10 minutes.

How to achieve this? Any suggestion?

Thank you sooo much.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
lilyyanAuthor Commented:
>>I wouldn't use the db for this unless the link is for one time only

Well, I need update one field(activeAccount) in a table. So user next time login, I could if his/her account is actived or not.
If don't use db, may you suggest which method is better?

Could you provide some simliar jsp sample?

Thanks for your attention.

0
 
KuldeepchaturvediCommented:
in this context, dont you think that 10 mins is a bit less... sometimes the mail may not be delivered to your users with in this 10 mins time span...
since you will be updating the database  for activation upon clicking on the link, I suggest to use the database and keep the validity for may be one day..

when you send the mail you can store today's date in the table and then when user clicks on the link you can check the system date with the date you have stored in the database.
use of session is not recommended for the simple reason that if user clicks the link in the email itself(which he most probably will).. then it will open up in a new browser ( i.e. with a new session!)
0
 
lilyyanAuthor Commented:
>>use of session is not recommended for the simple reason that if user clicks the link in the email itself(which he most probably will).. then it will open up in a new browser ( i.e. with a new session!)

Could you explain more about this. I'm still confused.

Well, I'm thinking in register.jsp , I will set a session called "activeTime" and the max. time for this seeion is. e.g 1hr.
In active.jsp, I will first retirve this seeion variable, if this seeeion has expired, then inform the user.
0
 
KuldeepchaturvediCommented:
If  I understand your requierment correctly then you will be sending this "activation" link to your user in a email...
if thats a correct assumption that session wont work because session is tied up with the browser your user is currently working.

now when user recieves your mail. he opens the mails and clicks on the "activation" link that you have placed in the email..
this clicking will open a new browser window for the user and hence it will not share the session you established in register.jsp
0
 
bloodredsunCommented:
Ah, now I understand, this is a continuation of the question you had earlier with activation of account emails. As Kuldeep says, don't use the session for this but just use a timestamp in the email. The standard is 30 mins in the environment I work but that is normally for forgotten passwords not account activation. I would say no more than 2 hours though.
0
 
lilyyanAuthor Commented:
Thanks for your suggestions.
Well, I'm still working on my program: )

>>this clicking will open a new browser window for the user and hence it will not share the session you established in register.jsp

Is there any way to let active.jsp know there is a seeion called "activeTime". I didn't  use a form in register.jsp.

If I'm right, there has to be a form which call another jsp pageB, so this jsp pageB will know there is a session was send to it ?


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now