Home Answers Viewqa JSP-Servlet how to prevent from navigating Back after logout or session expire in jsp

 
 


vikas pandey
how to prevent from navigating Back after logout or session expire in jsp
1 Answer(s)      8 months ago
Posted in : JSP-Servlet

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 Pages:
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
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 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
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
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
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 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
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
Logout?
Logout?  how to logout from a jsp page?   Hi to logout from Jsp Page.you should use session.invalidate() method. *khalidkhan
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 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
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
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
JSP Login Logout Example
JSP Login Logout Example In this section we will discuss how to create... the same session invalidate() method for ending the session or logout from... of user from the application. In this example we will use the JSP implicit object
back button issue - Java Beginners
, If you LogOut the button Check the session completely destroy... on Session visit to : http://www.roseindia.net/jsp/jspsession/ http...back button issue  Hello, I have a site that asks for user
logout - Struts
logout  how to make code in struts if i click the logout button then no body can back refresh the page , after logout nobody will able to check the page Thanks Anil  Hi anil, //... session.removeAttribute
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
login and logout
login and logout   > > > > hi, > >... home.jsp code i > created a login form and after submitting... button with value logout > > and in the action i had given the home.jsp
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
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
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
Login/Logout With Session
Login/Logout With Session       In this section, we are going to develop a login/logout application with session...;/action> <action name="logout" class="net.roseindia.logoutAction" >
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
session
session  how to implement login-logout session????   Please.../Logout.shtml http://www.roseindia.net/jsp/javascriptpagerefresh.shtml http://www.roseindia.net/jsp/loginstatus.shtml http://www.roseindia.net/struts/struts2/struts2
session tracking - JSP-Servlet
site how do i track his session activities....how to my pages will display his username on top of page( that is how do i transfer info from one page to other...session tracking  hi, i m working on a real estate web site....which
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
session management for login logout in php
session management for login logout in php  how to manage session for login and logout in php
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
session cookies expire - PHP
session cookies expire  when do a session cookies expire in PHP
should not go back to index.jsp when press on the link logout
should not go back to index.jsp when press on the link logout  Hello... get the session and on the same servlet page i give a link of logout.bt now... Logout.java.but now the problem is this ,when i press the back arrow on the browser
should not go back to index.jsp when press on the link logout
should not go back to index.jsp when press on the link logout  Hello... get the session and on the same servlet page i give a link of logout.bt now... Logout.java.but now the problem is this ,when i press the back arrow on the browser
should not go back to index.jsp when press on the link logout
should not go back to index.jsp when press on the link logout  Hello... get the session and on the same servlet page i give a link of logout.bt now... Logout.java.but now the problem is this ,when i press the back arrow on the browser
login-logout
login-logout  how to do login and logout using session in php
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
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 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
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
coding for logout - Development process
coding for logout  hi.. coding for logout using the session in jsp
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
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
JSP Session Parameter rewrite
illustrates you how to show session parameters in jsp. Here is the code... JSP Session Parameter rewrite   ... in jsp. JSP session provides methods like getCreationtime(), getLastAccessedTime
[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 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
logout problem
logout problem  I am stuck in my application --- hope anyone can take me out of this... the problem is -- when i logout , the user goes to logout.jsp (as simple), but when he presses back button , he again sees the page , where
Code to STOP Students from navigating anywhere else till the Online exam is over
Code to STOP Students from navigating anywhere else till the Online exam... working in on versions: 1) desktop based(Swings and panel) 2) web based (jsp &... or how to do so for BOTH VERSIONS i am using netbeans IDE but i will prefer

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.