how to prevent from navigating Back after logout or session expire in jsp

how to prevent from navigating Back after logout or session expire in jsp

Hii Sir, I am making a web app in which after logout one can go to back pages from the browsers back button which i dont want in my app.

Plz sir give me the desired code to solve this issue and plz specify where to use it

either in every page of in login page or at logout page.

Thank you Sir

View Answers

September 10, 2012 at 5:44 PM

Check out here for your requirement.

1)login.jsp:

<html>

<head>

<title>User Login</title>
</head>
<br>
<body Bgcolor ="#0099cc"><hr><hr>

<form method="POST" action="action.jsp">
<p><b>UserName:</b> <input type="text" name="UserName" size="10"></p>
<p><b>Password:</b>   <input type="Password" name="Password" size="10"></p>
<p><input type="submit" value="Submit" name="submit"><input type=
"reset" value="Reset" name="reset"></p><hr><hr>
</form>

</body>

</html>

2)action.jsp:

<%@page import="java.util.*" %>
<script>
function go() {
window.location.replace("logout.jsp",'window','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
self.close()
}
</script>
<%String str = request.getParameter("UserName");
session.setAttribute("UserName", request.getParameter("UserName"));%>
Welcome to <%= session.getAttribute( "UserName" ) %>
<% if (session.getAttribute("UserName").equals("")){%>
<a href="login.jsp"><b>Login </b></a>
<%}
else{%>
<a href="javascript:go()"><b>Logout</b></a>
<%}
%>

3)logout.jsp:

<%session.invalidate();%>
You have logged out. Please
<a href="login.jsp"><b>Login</b></a>









Related Tutorials/Questions & Answers:
how to prevent from navigating Back after logout or session expire in jsp
how to prevent from navigating Back after logout or session expire in jsp  Hii Sir, I am making a web app in which after logout one can go to back pages from the browsers back button which i dont want in my app. Plz
How to prevent from navigating to a page after reaching Login page using back button?
How to prevent from navigating to a page after reaching Login page using back... login page using back button and agin click browser forward button,the 2nd page session gets expired but on next click on forward button,the pdf document opens
Advertisements
How to disable browser back after logout - JSP-Servlet
How to disable browser back after logout  Dear All I created JSP... data. I dont want to see my old visited pages after logout or expire the session. Anyone having idea how to disable browser back button after logout, please
Session expire and back button in jsp and servlet .
Session expire and back button in jsp and servlet .  Hii Sir... to invalidate the session after a certain interval of time and after clicking logout button.Means that after session expiry time and logout action no one can access
How to prevent from navigating to ck buttonnext page when user reaches login page using back button
How to prevent from navigating to ck buttonnext page when user reaches login page using back button  Hi sir, I have created 2 pages, 1) Lo gin Page... goback to user login page using back button and agin click browser forward button
How to disable browser back and forward button after logout [in struts2 or jsp]
How to disable browser back and forward button after logout [in struts2 or jsp]  How to disable browser back and forward button after logout [in struts2 or jsp] I am using window.history.forward(); function
How to disable browser back after logout - JSP-Servlet
How to disable browser back after logout  thanks deepak, i tried but if i am clicking back still i can see my old pages. i copied your code in my logout page. please if you have any other solution, please give me
how can we prevent back option after log out.
how can we prevent back option after log out.  how can we prevent back option after log out
after logout the page is going back - Java Beginners
after logout the page is going back  Dear friends can any one help me urgently, how to restrict our jsp pages from going back after logout. i 've did... give details "How to logout the page" to solve the problem. Thanks
After Logout Back Button Should not work again
After Logout Back Button Should not work again  Hi deepak,, I am doing Login Page,.. IN That If Logout Then When I Click Logout Button It Should... be creating session and adding some attribute during login process of user. Please
Should not logout after clicking the back/forward button
Should not logout after clicking the back/forward button  Hi all I have wrote a code for login now. User is able to login but after logging in when he clicks on the back button user automatically gets logged out. very next
how to design a jsp page via link which will expire after 3 days if not use?
how to design a jsp page via link which will expire after 3 days if not use?   Link is in a mail and if changes occur it will update in database
how to design a jsp page via link which will expire after 3 days if not use?
how to design a jsp page via link which will expire after 3 days if not use?   Link is in a mail and if changes occur it will update in database
how to disable back button of a browser after logging in? - JSP-Servlet
how to disable back button of a browser after logging in?  how to disable back button of a browser after logging in?  where is the source code
session syntax for logout - JSP-Servlet
given JSP code that will help you to logout from the application...session syntax for logout  What is the syntax for writing session for logout page in login services ?  Hi friend<%@page import="
How to revert back ServletInputStream object after reading once. - JSP-Servlet
How to revert back ServletInputStream object after reading once.  Hi All, I am trying to get parameter from request object which is multipart/form.... My Q is how can I iterate request object twice? How we can revert back
Session Expire
Session Expire  Hello... i am new in JSP. i use in session.setAttribute and .getAttribute.But when i click on the sign out button i shows that the user is sign out but when i click on back button(chrom back button) it is again
UINavigationController Navigating to back
UINavigationController Navigating to back  How to navigate to previous screen or simply go back or simulate the back button programmatically in iOS? Thanks   Hi, You can use the following code
how to prevent no from unroundin off on clicking text box again in JSP and Jquery
how to prevent no from unroundin off on clicking text box again in JSP and Jquery  I am rounding off numbers entered in a text box in jsp but when I... on clicking outside It rounds off again, How can i prevent it from un-rounding off
how to disable submit button after login in jsp
on the back button in browser it stars displaying login page. How to prevent this? how... the Session setattribute in jsp Working with sessions JSP Login Logout Example...how to disable submit button after login in jsp  Hi, I have
session cookies expire - PHP
session cookies expire  when do a session cookies expire in PHP
session maintaining after logged in in jsp
session maintaining after logged in in jsp  Hi. I have created a login page. after the user logged in successfully if the user gives refresh the the control goes to the website home page. i want to retain in the same page
How to Auto Delete Bids after certail time expire.?
How to Auto Delete Bids after certail time expire.?  I am developing alibaba.com like website where after time expires ,buying request need to be deleted. So is there any idea experts have for this type of problem
How to Auto Delete Bids after certail time expire.?
How to Auto Delete Bids after certail time expire.?  I am developing alibaba.com like website where after time expires ,buying request need to be deleted. So is there any idea experts have for this type of problem
how to prevent user selecting past date from calender
how to prevent user selecting past date from calender  how to prevent user selecting past date from calender ex: today's date is 21st march user should not select 20th march or below
session management for login logout in php
session management for login logout in php  how to manage session for login and logout in php
logout problem.. - JSP-Servlet
done in the code i have used session object in project's servlet and jsp...(M.V.C),when a user login's and after doing some work he click logout he...logout problem..  hi... first of all thanks for ur
jsp logout code
for logout in jsp and also how to immplement it. thanking you...jsp logout code  hello sir, im doing jsp project, i have implemented the session code of jsp. session.invalidate(). but its not working. can u
php session for login and logout
php session for login and logout  Session management code to create a login and logout session in PHP. Thanks
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session   sig
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session   sig   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/bank.shtml
Simplest Login and Logout example in JSP
Simplest Login and Logout example in JSP   This JSP example shows you how to login and logout the session between JSP pages. JSP provide an implicit object that is session in which use to save
[JSP] How to pass back ID to previous page.
[JSP] How to pass back ID to previous page.  Hi experts, May I ask something. How to link a page to previous page which the content in previous page is selected from database where IDPRODUCT=". I don't know how to pass back
how to get a column values from a excel file after attaching it - JSP-Servlet
how to get a column values from a excel file after attaching it  hi sir, How to get a column values from a excel file after attaching it while... and get a values from that store that value in To input box.Please help me sir
Logout?
Logout?  how to logout from a jsp page?   Hi to logout from Jsp Page.you should use session.invalidate() method. *khalidkhan
logout - JSP-Servlet
logout  i want to know that (using only servlet technology not jsp) i create login page(html) ,registration.html, home page(servlet) and other pages. when i click the logout(hyperlink) then session is logout frequently
JSP Back Button
The Tutorial illustrate an example from 'JSP Back Button'. To understand... JSP Back Button          Jsp Back Button enables the user back
session.timeout and notification before session expire in java
session.timeout and notification before session expire in java  Hi... notification page when the session expires; but I want this to happen without user...; session timeout is 30 min; I would want the page to automatically forward to another
Logout - JSP-Servlet
Logout   HOW TO REMOVE SESSION ID.. IF SISSION LOGOUT . WHEN I PRESS REFRESH BROWSER DEFAULT SESSION ID WILL BE CREATED.FIND THE SOLUTION ABOUT TOTALY REMOVE THE SESSION ID ,SESSION GUESTNAME   Hi ramesh You
jsp-logout - JSP-Servlet
jsp-logout  hai friends please provide me a powerful login & logout programs for my web application regarding my project. thanks...://www.roseindia.net/jsp/loginstatus.shtml http://www.roseindia.net/jsp/loginbean.shtml
jsp - session - JSP-Servlet
JSP - Session  How to manage session in JSP
How to use filter to redirect to login page after session timeout
How to use filter to redirect to login page after session timeout  hello Sir, I have to make a web application in which i have to give session... then automatically it should redirect to login page from where user has to login again
How to use filter to redirect to login page after session timeout.
How to use filter to redirect to login page after session timeout.  ... session timeout . means if screen is inactive for a particular period of time then automatically it should redirect to login page from where user has
How to use filter to redirect to login page after session timeout.
How to use filter to redirect to login page after session timeout.  ... session timeout . means if screen is inactive for a particular period of time then automatically it should redirect to login page from where user has
logout validation - JSP-Servlet
logout validation  sir in my application when i m logging out.it is still going to the back page.so, kindly send me the code which can restrict this. Thanking you.  if you are using the session value, please
Logout - JSP-Servlet
Logout  HOW TO SESSION REMOVE.. SESSION.INVALIDATE(); THIS FUNCTION... SESSION WILL BE REMOVE AND REFESH THE BROWSER THE SESSIONS WILL BE CREATED? HOW.../Logout With Session, the specific url is as below: http://www.roseindia.net
Clearing session in jsp
Clearing session in jsp  i have developed a web appilcation using jsp and when user try to logout, session is not clearing even though i have used..."); session.removeAttribute("type"); When i press back button of browser it redirects to previous page
logout problem?? - JSP-Servlet
logout problem??  sir, the logout code which u have send... not happen.to logout properly i think we should empty or clear the browser cache regarding that session object which used in particular application.this doesnt
Mantain a Session in one application after opening another third party application - JSP-Servlet
Mantain a Session in one application after opening another third party... not sure How would we get the session with that ID and keep the session alive... up a third party application in another widow., and session in the current
logout code in JSP
logout code in JSP  im using session.invalidate() for logout but its not working

Ads