Advertisement

12.20.2005 at 02:24AM PST, ID: 21670356
[x]
Attachment Details

How can I prevent visitors accessing pages in my website even if they know the URL?

Asked by avanworld in Java Programming Language

Tags: prevent, accessing, from

Hi,

I am creating a three step registration/feedback process where user has to fill up some details from Step1 through Step3.
[Please note that there is no authentication or login process, This feedback is anonymous so I cannot capture any user information].

There are 4 files

index.jsp //This is from where they have to start
step1.jsp
step2.jsp
step3.jsp

How can I prevent visitors accessing pages in my website even if they know the URL?

I don't want the customer to move to step1 to step3 without reading the index page
(A link is provided in index page to go to step1) as shown below

<a href="" onClick="window.open('step1.jsp',null,
    'height=screen.height,width=screen.width,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes')">Click here to goto Step1</a>

But I have placed a Javascript to check whether the user is coming from index.jsp from this server or not. This works very well for Mozilla and Firefox but Internet Explorer returns a null value for document.referrer when pages are accessed in this manner (using window.open).

<script language="Javascript">

        //Provide a list of allowed sites
      var site1="http://localhost:8080/app/index.jsp";//Developer Machine, Only for testing purposes
      var site2="http://www.mysite.com/app/index.jsp";//Deployed Server

      if (document.referrer&&document.referrer!=""&&(document.referrer.indexOf(site1) >= 0||document.referrer.indexOf(site2) >= 0)) {
              //alert('Thanks for visiting this site from '+document.referrer); //Allow page to render or skip this alert
      } else {
              alert('You are not allowed to access this page directly, you will be automatically redirected to the page from where you have to start');
              window.location.href="index.jsp";              
      }  

</script>

I have 2 questions to ask

How can I make the above script work in Internet Explorer?
Is there an alternate way to implement this technology with JSP/Servlets?

My aim is not to allow visitors to access step1.jsp, step2.jsp or step3.jsp directly from the browser window(by typing the URL in Address bar/Location bar) even if they know the URL like this.

They have to follow the sequence : index.jsp -> step1.jsp -> step2.jsp -> step3.jsp

http://mysite.com/app/step1.jsp //This should not be allowed
http://mysite.com/app/step2.jsp //This should not be allowed
http://mysite.com/app/step3.jsp //This should not be allowed

Please help.Start Free Trial
[+][-]12.20.2005 at 02:45AM PST, ID: 15517392

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 02:45AM PST, ID: 15517393

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 03:42AM PST, ID: 15517542

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.20.2005 at 04:43AM PST, ID: 15517815

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: prevent, accessing, from
Sign Up Now!
Solution Provided By: bloodredsun
Participating Experts: 3
Solution Grade: A
 
 
[+][-]12.20.2005 at 04:44AM PST, ID: 15517820

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 04:50AM PST, ID: 15517845

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 04:53AM PST, ID: 15517861

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 04:56AM PST, ID: 15517873

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 04:57AM PST, ID: 15517879

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 06:29AM PST, ID: 15518506

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.20.2005 at 07:05AM PST, ID: 15518769

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32