Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding session  RSS feed

 
dpriya pratheep
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I want to do one program ,where i want to set the session.

If the user entered into the page without login should not be allowed.

For example if the knows the address of the page he should not allowed to login in directly without proper login.

I know how to use the Javabean.In the page how i will check he is logined user?

please help me
thanks
priya
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checking on the page is a very poor place to do it. Rather, you should check before the page is even displayed in a Servlet filter.
 
Danilo Dadonas
Ranch Hand
Posts: 59
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. In this case, you can use the security options of your container (Tomcat, JBoss, etc). You can use Tomcat with JDBC Realm. The login page need to have an input named "j_username", other input named "j_password" and the action of the form "j_security_check". There is an excelent example about it in the book Head First - Servlets and JSP.

References:
Tomcat Realms
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like he already has a login mechanism, why would he switch to the container-managed login which offers little in the way of control?
 
Danilo Dadonas
Ranch Hand
Posts: 59
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he means that if someone knows some url that requires authenticated access like http://www.myapplication.com/reports/somereport.jsp.
If "/reports/*" or "/reports/somereport.jsp" are referenced in the <security-constraint> of the Deployment Decriptor, the container will submit the user to the login page if the one is not logged on. In this case, anyone code is necessary to check if the user is logged on, the container does the work.
 
Suraj Berwal
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Priya,

You can also search the forum for existing threads on the topic. One good link is here

Friends,

Priya is a she not a he.



Thanks,
Suraj
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!