| Author |
create a session for user and pass the objects to next servlet
|
mahe kum
Greenhorn
Joined: Oct 11, 2012
Posts: 2
|
|
Hi All,
I m totally new to the environment.please guide me how to create a session for user and how to pass the objects to next servlet. for ex i have 4 servlet pages like login.jsp,insert.jsp,update.jsp,delete.jsp. a user should be able to access these pages only after loging in successfully . i have completed the login page,insert page ,update page and they are working proprly. i m running this web app in tomcat with a user database.
|
 |
vinnu kumar
Greenhorn
Joined: Sep 10, 2007
Posts: 12
|
|
|
HttpSession session object and Request Dispatcher for forwarding to your insert ,update.....
|
 |
mahe kum
Greenhorn
Joined: Oct 11, 2012
Posts: 2
|
|
Hi Vinnu,
I m really glad to see the reply soon. vinnu i have my web app ready with database connectivity.it is a ticketing tool. all mmodules are working fine. no need of forwarding pages. i have set frames after logging in. so i have refference link to get the pages in next frame. all i want to do is to create session to users.
http://localhost:8080/ticketOnline/ is my project but with even logging in if i type http://localhost:8080/ticketOnline/insert.jsp it is taking me to the insert page. this is my problem.
|
 |
shiva kumar g
Greenhorn
Joined: Jun 08, 2010
Posts: 6
|
|
Hi,
As soon as you login you just generate one query string and append to all URL's and put this into session with some attribute. In each and every page get the query string and check whether the query string is there in the session. After logout you just invalidate the session object. So in each page just add the code to check whether session is null, if not check for query string in session and from request url are same.Otherwise just redirect to Login page if fails above condition.
Hope this may help to you.
|
 |
Prasad Krishnegowda
Ranch Hand
Joined: Apr 25, 2010
Posts: 503
|
|
mahe kum wrote:all i want to do is to create session to users.
You don't need to create session, the browser creates it, we just need to get the session, using request.getSession();
Did you mean, even without logging in?
|
Regards, Prasad
SCJP 5 (93%)
|
 |
Prasad Krishnegowda
Ranch Hand
Joined: Apr 25, 2010
Posts: 503
|
|
shiva kumar g wrote:As soon as you login you just generate one query string and append to all URL's and put this into session
Just putting an attribute into session, telling whether the user has logged into the application is enough, there is no need to append any query string to all URL's for this purpose....
|
 |
 |
|
|
subject: create a session for user and pass the objects to next servlet
|
|
|