Log out from website

Log out from website

what is the code to how to log out from the website?

View Answers

March 17, 2008 at 9:23 PM

Java Example code of Login and Logout from the applications...

LoginPage.jsp

<html>
<head>
<title>login page in jsp</title>
</head>
<body>
<table border="1" width="30%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<form method="POST" action="loginAction.jsp">
<h2>Login Page In JSP</h2>
<table border="1" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="50%"><b>Username:</b></td>
<td width="50%"><input type="text" name="username" size="25"></td>
</tr>
<tr>
<td width="50%"><b>Password:</b></td>
<td width="50%"><input type="password" name="password" size="25"></td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</td>
</tr>
</table>

</body>

</html>

loginAction.jsp


<%@ page language="java" import="java.sql.*,java.util.*,java.text.*" %>

<%

Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
java.util.Date date;
String s=null;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String username=request.getParameter("username");
String password=request.getParameter("password");

int val = st.executeUpdate("insert userlogin values('"+username+"','"+password+"')");

session.setAttribute("username", request.getParameter("username"));%>
Welcome to <%= session.getAttribute( "username" ) %>

<% if (session.getAttribute("username").equals("") && session.getAttribute("password").equals("")){%>
<a href="loginPage.jsp"><b>Login </b></a>
<%}
else{%>
<a href="logoutAction.jsp"><b>Logout</b></a>
<%}%>
<%
con.close();
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>

- - - - -- -
logoutAction.jsp

<%@page import="java.util.*" %>

<%session.invalidate();%>
You have logout. Please try again
<a href="loginPage.jsp"><b>Login</b></a>
----------

Using the above given code you can write a application the will allow a user to log in and log out from the application using JSP

JSP Tutorials
http://www.roseindia.net/jsp










Related Tutorials/Questions & Answers:
Log out from website - JSP-Servlet
Log out from website  what is the code to how to log out from the website?  Java Example code of Login and Logout from the applications... a user to log in and log out from the application using JSPJSP Tutorialshttp
log out
log out  how do i create a log out on a project without it exiting system so it does not reload again
Advertisements
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
auto log out the application if its inactive for longer period
auto log out the application if its inactive for longer period  hi all, Please tell me how to auto log out the application if its not performing any activity for longer period in jsp i tried to use session.setMaxInactiveInterval
How to convert http website into Https from java?
How to convert http website into Https from java?  could any one tell me how to convert http website into Https from java
To download a website from a given url. - JSP-Servlet
To download a website from a given url.  write a program to download a website from a given URL.it must download all the pages from that website.it should take the depth of retrieval from user input.all the files pages must
download xml file from website using java code
download xml file from website using java code  how to download xml file from website using java code
how to scrape the data from one website another website using html dom parsing in php
how to scrape the data from one website another website using html dom parsing in php  " how to scrape the data from one website another website using html dom parsing in php" i'm trying this one .please provide code for me
how to write to java program to get the particular data from the website
how to write to java program to get the particular data from the website   i have to get the particular data by selecting the just numbers.. from the site .. how to get the ful details from the website by clicking the number
how to send sms from my website to mobile of particular user.
how to send sms from my website to mobile of particular user.  i had created a website and aim of pjt is whoever the client register for site with their mobile number daily one health tip is to sent to their respective mobiles
How to Get The Data from Excel sheet into out jsp page???
How to Get The Data from Excel sheet into out jsp page???  How to Get The Data from excel sheet to out jsp page in webApp
Take print out from printer at client machienusing jsp - JSP-Servlet
Take print out from printer at client machienusing jsp  Sir/Mam I want do is to take out print out of my report which will be created from the Mysql database with out displaying him/her the results or report from the printer
how to get data from list to map with out using a loop?
how to get data from list to map with out using a loop?  List list=new ArrayList(); list.add("raja"); list.add("1"); list.add("puja...("15"); how to get this data into map with out using a loop. i want
Sending error code to access log of tomcat server from Action class
Sending error code to access log of tomcat server from Action class  How to send an error code (500) to access log file when we get null value in an if condition in Action class? Is anyone aware of this! Thanks
How to delete content of a log file from linux terminal?
How to delete content of a log file from linux terminal?  Hi, My... running queries. But first I want to delete the content of the /var/log/slow... of the mysql log file: cat /dev/null > /var/log/slow-queries.log Thanks
website
website  i have uploaded website .website is woking properly in chrome & firefox but not in IE
website
website  How to paste data directly on any website' text box
website
website  design and coding of first page of any forum website in jsp
Fetching data from excel file on other website and display in interactive graph form
Fetching data from excel file on other website and display in interactive graph form  Hello, I am making a website using HTML and CSS, I am done... pull data data from those and generate graphs out of it? I really need it urgently
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list...=mysql_query("select * from age order by Age_Desc"); while($row_list=mysql_fetch
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list...=mysql_query("select * from age order by Age_Desc"); while($row_list=mysql_fetch
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list...=mysql_query("select * from age order by Age_Desc"); while($row_list=mysql_fetch
Writing articles,write articles earn money,earn money from website,articles income
of earning from your website.  Here are the steps you need to follow to make... website. You can make money from different affiliate programs, many paid... or investing huge time. Writing the articles for website for making money is much
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap   i want to create invoice report .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap   i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
How to read a log file from server location and send a mail when exception occurs.
How to read a log file from server location and send a mail when exception occurs.  HI, How can i read the 2GB to 4GB log file from server. and i need to send a mail when exception occurs. Thanks RajeevADS_TO_REPLACE_1
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  Hi All. please give me your valuable advise for below requirement.. I have... one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
calling java method from html form with out using javascript - JSP-Servlet
calling java method from html form with out using javascript  How can i call java method from a HTML form, java script should be disabled?  Hi <html><head><title>Test Input Validation</title><
log in
log in  sir i designed one login.jsp page with one form, username,login,and one submit button .if i enter username and password its been verify the mydatabase in in table in the field of username and password while it s correct
How can I POST form data from a C#/ASP.NET to a remote website?
How can I POST form data from a C#/ASP.NET to a remote website?  I'm trying to send data to a remote PHP website. I want to send the data in sessions using HTTP POST. The thing is, my website is built in C#/ASP.NET, and I don't
Retrieve a list of words from a website and show a word count plus a specified number of most frequently occurring words
Retrieve a list of words from a website and show a word count plus a specified... the document text from the web (provided by utility class) 2.Filter the desired... have added blocks of commented out sections in which the new code should go
Website Development Services
Website Development Services We are IT company providing Website development..., Ajax, jQuery to design and develop unique websites. We are offering Website... high impact website for our clients. We create user friendly design and code
Custom Website Programming
Custom Website Programming We offer Custom Website Programming services to our... development center in India. Our custom website programming services is very cost effective and delivers high quality website applications. The Custom Website
Website deployment
Website deployment  Hi, I have created a website using servlet and jsp. I'm through with it now i want to deploy my website locally..., till now i was viewing the website by pressing f6 it is working fine. I also
Website deployment
Website deployment  Hi, I have created a website using servlet and jsp. I'm through with it now i want to deploy my website locally..., till now i was viewing the website by pressing f6 it is working fine. I also
website - WebSevices
website  hi .how to update website
hosting the website
hosting the website  what are the steps for hosting the website
Is there anyone out there?
Is there anyone out there?  Hi please could somebody respond as I am seeking advice but not getting any and do not know whether or not to continue using this site
Count Palindromes from the string
Count Palindromes from the string In this section, we are going to find out the number of palindromes from the string. For this, we have allowed the user to input a sentence or string. This string is then break down into tokens using
Google news approved website for sale
can start your work within a day by buying news approved website from me... in the news domain from our help. Our news approved website will provide you...Google news approved website for sale - Have several domain names approved
Google news approved website for sale
Websites/Domains from our News approved website for sale list then contact us... news approved website from me instead of waiting for months to get started...Google news approved website for sale - Have several domain names approved
Extract website
Extract website   can you help me to write this ???>>write a program to extract data from AirAsia.com to get flight information, specifically, for a trip from [A] to [B] on specific date. You can use whatever libraries
Link to a website
Link to a website  I have created a mobile application.Now I want to insert a link to a website so that when mobile user selects that link he is directed to that website
ASP.net website
ASP.net website  Sir i want to how to lonch our website in internet pleas help me i have created a website in asp.net it is running in localhost but i want ren it in internet server
Real Estate WebsiteTemplates
or Website templates to boost their business. We offer various predesigned Website templates for big infrastructures, Builders, Properties dealers to ease them out from... sections of real estate companies requirements. Our Website temples
To Develope an Website
To Develope an Website   Hi there, I am fresher,very new to CVS, and I want to create a website in Eclipse IDE, But I don't know how to create, please help me. What I did is I had created two XML files, web.xml
Make A website
Make A website  How expensive(hire someone) or hard would it be to create a website like this? I want to build a website where people can be users of the website with a small profile. Their is a point system (kinda like money
Hotel Website Template Designing
Are you looking for sensuous and splendour Hotel Website Templates for attracting enormous customers only at just a click away? You have reached at the right spot
Static Website Designing
Static Website Designing A static website is a site of static web pages... information in response to all download requests from all users. It displays the same information for all users, from all contexts. The navigation is performed
Log-in Valdidation
Log-in Valdidation  how to create login validation in jsp

Ads