This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
I have designed a website using servlets which enables them to shop and chat. i have an administrator account for this site which allows me to get disable a user account.. Supose this user is online at the moment. I want him to be redirected immediately to an error message. For this When they login i am storing their response object into a static vector. Now i am able to get hold of this response object but am unable to redirect the user to the error page. I am not getting any errors though. please help me out - Prashant
David Freels
Ranch Hand
Joined: Feb 01, 2001
Posts: 102
posted
0
I may be misunderstanding you, but I think what you need to do is store a value in the session object and upon the user sending a request to your site, check this variable and then perform your redirect. You cannot redirect a user after they have received a previous response because the browser closes communication. So, you must wait for them to send another request. David Sun Certified Programmer for the Java2 Platform
Ashwin Desai
Ranch Hand
Joined: Jul 17, 2000
Posts: 124
posted
0
Hi Prashant, The response object is valid only for a particular interaction with the server. It is not same across the entire session. If the user does not make a request to your servlet/JSP page, you will not be able to get the response object, then there is no way you can redirect him to another page. This is because HTTP is a stateless protocol and does not remember interaction history with the server. The browser makes a different connection with the server for each request. But, you can always trap all requests and check each time whether the user account is enabled/disabled and decide the course of action. Hope this helps. Ashwin.
Andrew Shafer
Ranch Hand
Joined: Jan 19, 2001
Posts: 338
posted
0
Firing from the hip, it seems like you might be able to do it with an applet on the client side, but if it is just their browser then you must wait for another request before they will get any message. I haven't tried to do it or thought it through, but it seems like an applet could respond in real time (connection speed time) to the session invalidate() or something similar.
!_I_Know_Kung_Fu_!
Desai Sandeep
Ranch Hand
Joined: Apr 02, 2001
Posts: 1157
posted
0
Hi Prashant, I have designed an login/logout JSP site and had a requirement very similar to yours.I was storing the valid (not disabled) users in the application implicit object.When the user is disabled, the user entry is removed from the application object. There is a check at the start of my every JSP page, which checks if the user is valid or not.Only if his id is enabled, he is allowed access to the page. If not, he is forwarded to an error page. I have used the <jsp:forward> tag for this purpose. Hope this helps. Regards,
Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
IBM Enterprise Connectivity with J2EE Scored 72 per cent
Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
prashant sreenivasan
Greenhorn
Joined: Nov 19, 2000
Posts: 6
posted
0
Thank you all for your replies.. What you all say is correct.. but is there any way of redirecting the user without him requesting another page.. Prashant
Andrew Shafer
Ranch Hand
Joined: Jan 19, 2001
Posts: 338
posted
0
Http is a "stateless" protocol. If you are only using http the client must make a request. With an applet you could communicate to the servlet through sockets without a client side request.
bob walker
Greenhorn
Joined: Feb 20, 2001
Posts: 14
posted
0
Originally posted by prashant sreenivasan: Thank you all for your replies.. What you all say is correct.. but is there any way of redirecting the user without him requesting another page.. Prashant
I would invalidate the session in your static storage. It would allow you to force the user to the error page on the next request. You can't determine if the user is still reading the page or has closed his browser.