| Author |
code for logout from jsp page
|
sunita shaw
Ranch Hand
Joined: Apr 06, 2003
Posts: 45
|
|
i'm in an urgent need for a complete code for logout from a jsp page.i've tried a number of ways but things didnt work out. just see if anyone can help me out as soon as possible.
-Thanks
|
 |
amanda wu
Greenhorn
Joined: Mar 16, 2003
Posts: 25
|
|
|
cannot just use "session.removeAttribute()"?
|
 |
Praful Thakare
Ranch Hand
Joined: Feb 10, 2001
Posts: 613
|
|
Hi sunita Try this out At starting of ur jsp page include a file say checksession.jps which will look somewhat like this CHECKSESSION.jsp <%@ page language="java" import="java.sql.*"%> <% if(session.getAttribute("SomeAttribute")== null) { give ur message and redirect to some page say login page ex:- out.println("<script>parent.location.href='Login.jsp'</script>"); } %> and on logout write this code <% session.invalidate(); out.println("<script>parent.location.href='Login.jsp'</script>"); %> Hope this solves ur problem cheers [ April 10, 2003: Message edited by: Praful Thakare ]
|
All desirable things in life are either illegal, banned, expensive or married to someone else !!!
|
 |
sunita shaw
Ranch Hand
Joined: Apr 06, 2003
Posts: 45
|
|
Thanx hth and Praful for the immediate help that you provided me .Praful your code was of greate help . it really worked perfectly well. thanx once again
|
 |
BenoƮt de Chateauvieux
Ranch Hand
Joined: Aug 10, 2007
Posts: 183
|
|
I know this thread is very old...
But for the archives:
I wrote it like that:
|
SCJP5 | SCBCD5 | SCEA5 Part 1
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
Even in 2003, the use of scriptlets in JSP pages was discredited. Doing so in 2009 is just .
And, please read this.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Parth Chavda
Greenhorn
Joined: Apr 21, 2013
Posts: 5
|
|
Hey Friend use this code in jsp page
<%
if(request.getParameter("logout")!= null)
{
session.removeAttribute("uid");
session.invalidate();
response.sendRedirect("index.html");
}
%>
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
Parth Chavda wrote:Hey Friend use this code in jsp page
Again, as already pointed out. Java scriptlets should no longer be used in JSP pages.
|
 |
 |
|
|
subject: code for logout from jsp page
|
|
|