Home Answers Viewqa JSP-Servlet Log out from website

 
 


Parveen
Log out from website
1 Answer(s)      5 years and 3 months ago
Posted in : JSP-Servlet

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 Pages:
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
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
log in page
log in page  hi all i want to create a login page in jsp which should be validated using ajax. please help me dong that with code...   Here is a jsp example that accepts username and password from the user and check
failure to log in
failure to log in  <blockquote> <p>Blockquote</p> </blockquote> <p>&lt;%@page contentType="text/html"%>... from customer_details where user_name=? and password
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
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
The Scannability of your website
The Scannability of your website   ... of the users 79% scan the pages of a website and do not read it word by word. The content... stand out by highlighting. As compare to a print document the number of words
JSP cannot log to FileAppender - Log4J
method. But when the LogClass is called from jsp file, no log file is created...JSP cannot log to FileAppender  Hi, Thank you for your attention... Log4j. At the moment, it logs fine to console when run from class main method
Creating a log in a text file - Applet
Creating a log in a text file  Hey there, I have created an applet... that keeps a log of the time of when the application is run and closed, every... file writer for when the application is run, but can't figure out a way to write
Website Designing Services
the output from the front-end. A web designer designs the web page or website using...Website Designing Services A website is like a book that contains information on a single or more topics while a web page is a page of the website similar
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
Log In Form Validations - Java Beginners
Log In Form Validations  Good Morning Sir ,I have Created Log in Form with Databse Connectivity and i have took two JTextFields 1)USERNAME 2...(); ResultSet res = st.executeQuery("SELECT * FROM login where username
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
What is Website Redesign
and market. When you improve your website, make sure that it turn out...What is Website Redesign Website has become a prominent and essential media in the fastest growing Internet market nowadays. Website has emerged
Cafe and Restaurant Website Design
Cafe and Restaurant Website Design We provide high quality Cafe and restaurant website design services. Our highly qualified website designer... and maintaining websites for cafe and restaurant industry. A website is the virtual
Dating Website Development
Dating Website Development We provide high quality online dating website development services. Our highly qualified website designers and development team... industry. A website is the virtual representation of a company
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
Java error log
Java error log       Java error log is a error that arises due to internal error. A error logger is simple an object that is used to show an error log message
keeping log of page load - Java Beginners
keeping log of page load  Hello, I have a project and I need... it loads very nicely but sometimes it doesn't load proper way and it times out. I... to keep a log of if the page has succesfuuly loaded or not. It means I want to keep
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
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
SEO Article Website to Increase Traffic,Increase Visitors using SEO Article Website - SEO Tips and Articles
Increasing SEO Article Website Traffic Instantly Are you searching... towards your website instantly? If this is what you desire then read on for finding the solution. Out of all the websites on the Internet, it's a well
Website Development Applications ? Design Your Own Website At The Drop Of A Hat
, it can be hard to create a website from scratch without the risk...Website Development Applications – Design Your Own Website At The Drop... a lot you will know that in order for you to want to visit a website it has to look
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 Rajeev
Dynamic Website Designing
Dynamic Website Designing The Dynamic sites differ from the static in terms... that allow easy upgrade and maintenance of website with out any technical knowledge... and appears when it is asked to access. Dynamic website is quicker in uploading
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 deployment on LAN
Website deployment on LAN  I have created a dynamic website in netbeans. Now i have to host the website on LAN so that by typing the URL of the project the users are able to view the content from their end. I have no idea
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
Out Of Memory Exception Erorr
Out Of Memory Exception Erorr  hello how are you?I hope you are fine I'm using jgrasp program my problem is in java programming my program compiled...: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main" I
give information or website address
give information or website address  hi i want u r help .... i m finding code for constructing graph in java but during execting them i have... help me out
SQL Out Parameter
from SQL Out Parameter .In this Example we create a procedure 'abc... SQL Out Parameter       SQL Out Parameter allows the stored procedure to the pass data value 
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
Discounted Website, 50% Discount on website,Website Rs. 5000/- a year!
links from premium website PHP Support This offer is valid only till 31st... Get Website for your business! Only for Rs. 5000 a year! Get professionally designed website for your business at 50% discounted rate
Log-in Valdidation
Log-in Valdidation  how to create login validation in jsp
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
Web Design Packages, Website Design Packages
Custom Website Design for Business Custom Website Design has become one... efficient custom website designing professionals to present a magical site... the customized website most as the designed site according to their requirements, brand
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
Security Measure of Website
Security Measure of  Website   ... from coding to running the site without any chances of hacking, fetching, or malicious attack on the site. During development, the programmers need to check out
how to build a website
how to build a website  i hv developed i dynamic web project using eclipse,now i want to convert this project into an one touch executable software .is it possible to do the same.?if anyone knows it plz help me out
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
website deployment - JSP-Servlet
website deployment  Hi All, Requirment: To fetch records depends on the scenario from database and display on webpages in a grid format... framework : I am able to manage to fetch records from database using Java Beans
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
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
log 4j
log 4j  what is log4j? can you give me clear information about log4j?   Please go through the following link: log4j Tutorials
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

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.