aspose file tools*
The moose likes Servlets and the fly likes cookie and login Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "cookie and login" Watch "cookie and login" New topic
Author

cookie and login

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
I have created a small application where first apears a login page and than user should be able to access other pages.

how do i stop user from direct accessing other pages.

like this is the url of login page


and user should not be able to access the c_voucher link before going through login page.



how do i achieve that


Jigar Naik


Rao Raghu
Ranch Hand

Joined: Jan 05, 2007
Posts: 100
By maintaining sessions.

You can retrieve his username and assign it to a hidden-type and validate the same before each page displays the contents. Better to use servlets.


RAGHU<br /> <br />"When the going gets tough, the tough get going"
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
can you please explain in more detail.
Rao Raghu
Ranch Hand

Joined: Jan 05, 2007
Posts: 100
When the user logs-in retrieve his username like:



now set this as a hidden type:



In the next jsp validate it like:



this is a rough presentation, i hope you might have got the concept now.

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
ye gotcha... Thanks a lot
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you haven't already, read up on filters.

They're perfect for this because they can be applied to both static and dynamic content vi configurations settings in your web.xml file.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
 
subject: cookie and login