简体   繁体   中英

To redirect to login page when url is entered in address bar

I have html pages in my java web application,with business logic handled in servlets. If the url of any page is directly entered in the browser address bar i need to redirect to the login page.Can someone help me on how i can achieve this feature.

Thanks in advance.

You can use security framework which automatically redirects you to login page once unauthenticated. It is more complicated but it is should be more reliable in long run. Check this out: Apache Shiro.

When user loading page, servlet calls DAO to load data from database. You can check session/cookies/request in servlet, if this user have token to access the data and sendRedirect to login page if not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM