• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

code for logout from jsp page

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cannot just use "session.removeAttribute()"?
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
sunita shaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this thread is very old...
But for the archives:

I wrote it like that:
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even in 2003, the use of scriptlets in JSP pages was discredited. Doing so in 2009 is just .

And, please read this.
 
Greenhorn
Posts: 5
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Friend use this code in jsp page

<%
if(request.getParameter("logout")!= null)
{
session.removeAttribute("uid");
session.invalidate();
response.sendRedirect("index.html");

}
%>
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic