• Post Reply Bookmark Topic Watch Topic
  • New Topic

restrict access to a static web site folder  RSS feed

 
mike lan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have a web site in static html files contained in a folder, that I want not to be public seen to anyone visiting the site,
but only though a login and password page compared with login and md5 password on a postgresql table
I've googled and found that I cant put the folder on web-inf folder but how do I "redirect" the user on the "index.html" ?

grateful for anyone taking time to reply
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just use a filter?
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mike lan wrote:
I have a web site in static html files contained in a folder, that I want not to be public seen to anyone visiting the site

Ok. I just posted this in another thread. If you are using Tomcat, you can use the security-constraint to force login. Look in the Tomcat manager webapp web.xml for an example.


but only though a login and password page compared with login and md5 password on a postgresql table

Now you are talking about possibly creating a DataSourceRealm, if you want to store the user/password in a database. Not impossible. Look at the Tomcat docs: http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html#DataSourceRealm


I've googled and found that I cant put the folder on web-inf folder but how do I "redirect" the user on the "index.html" ?

If you want to redirect, you can always use a meta-refresh tag in a empty index.html that redirects to some other page, but you don't need this if you use the security-constraint option.
 
mike lan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Why not just use a filter?


sorry for my ignorance , what's a filter ? a example or link ? if possible

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mike lan wrote:
sorry for my ignorance , what's a filter ? a example or link ? if possible


Filters in Java allow you centralized management of tasks such as authentication, compression, logging, image conversion, and localization of web content. Use can use a filter mapping to the particular url. For example,

So, for the specified url pattens, the specified filter will be invoked. Then within the filter, you can authenticate the user, and if he/she already authenticated, he/she can proceed. Otherwise, redirect to login forms. Here, you can use what ever authentication method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!