jhazard
asked on
.htaccess question
Hi
I am developing a site using jsp/java/tomcat and oracle. I understand if I put the .htaccess file in the root of my webserver this should password protect my web pages.
Is that it? Do I need to add any code? If so can someone give me an example.
Thanks
I am developing a site using jsp/java/tomcat and oracle. I understand if I put the .htaccess file in the root of my webserver this should password protect my web pages.
Is that it? Do I need to add any code? If so can someone give me an example.
Thanks
You have an interesting problem here and I can think of a few SIMPLE ways to go about it.
the basics here are counters. You want to see if the page has been loaded more than once.
The first thing to do is when the page is loaded (for the first time) check for an existing counter.. if it exists increment it and if it doesn't exist set it 1.
If counter > 1 then redirect to login page.
The different approaches that I mentioned are in the ways of storing the counter.
1. cookies (page specific of course)
2. url params
3. session var (page specific of course)
Does that work for what you want?
CJ
the basics here are counters. You want to see if the page has been loaded more than once.
The first thing to do is when the page is loaded (for the first time) check for an existing counter.. if it exists increment it and if it doesn't exist set it 1.
If counter > 1 then redirect to login page.
The different approaches that I mentioned are in the ways of storing the counter.
1. cookies (page specific of course)
2. url params
3. session var (page specific of course)
Does that work for what you want?
CJ
sorry the second comment was posted in the wrong question... I am losing it :-)
CJ
CJ
ASKER
Thank you for that but I'm still not clear on what else it is I need to do aside from adding the .htaccess file to my webserver. What code do I need to add?
once you create .htaccess in the directory that you want to protect. Then you must create the htpasswd file.
the htpasswd file is created by typing:
htpasswd -c .htpasswd username
at the command prompt in the directory that you want protected.
Now after you type the command you will be asked to enter the password.
repeat the command for each user.
That should be it.
CJ
the htpasswd file is created by typing:
htpasswd -c .htpasswd username
at the command prompt in the directory that you want protected.
Now after you type the command you will be asked to enter the password.
repeat the command for each user.
That should be it.
CJ
ASKER
I'm assuming I should have to set environment variables in Java. How do I do that (excuse me but I have limited experience with Java).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help and Thanx for the "A".
CJ
CJ
http://www.cgiextremes.com/extras/Tips_Tutorials/htaccess.html
http://www.javascriptkit.com/howto/htaccess3.shtml
http://faq.web2010.com/htaccess.htm
http://faq.clever.net/htaccess.htm
Now having given those URLs there are other means of authentication in the world of Server Side Java:
two popular options:
1. Realms (JDBC, etc)
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/realm-howto.html
http://www.onjava.com/pub/a/onjava/2001/07/24/tomcat.html
http://www.onjava.com/pub/a/onjava/2002/06/12/form.html
2. Filters
http://www.fawcette.com/javapro/2002_02/magazine/features/kjones/
Option 1 being the most popular and optimal way to go.
CJ