Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Log out from website

Have Programming Question? Ask it here!
 
 
 


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


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


Advertisement
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
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
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
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
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
website
website  i have uploaded website .website is woking properly in chrome & firefox but not in IE
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
website
website  design and coding of first page of any forum website in jsp
website
website  How to paste data directly on any website' text box
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
Log-in Valdidation
Log-in Valdidation  how to create login validation in jsp
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
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
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
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 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
error log
error log  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details-------------- Table
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
Writing Log Records to a Log File
Writing Log Records to a Log File       This section demonstrates for writing log records to a log file. Logger provides different types of level like: warning, info
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
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
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
error log and send Database
error log and send Database  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details
Writing articles,write articles earn money,earn money from website,articles income
website. Once your website is uploaded and running you can think of earning from your...;monetize"  the traffic of your website. You can make money from... from web site keep on writing and adding more article to your website
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
Error in log file
Error in log file  Hi, I AM using Apache tomcat 6.0.16 server... of executing project i get following errors in "Apache Tomcat 6.0.16 log". Apr 17, 2011 11:57:57 AM org.apache.catalina.core.ApplicationContext log INFO: Marking
Error in log file
Error in log file  Hi, I AM using Apache tomcat 6.0.16 server... of executing project i get following errors in "Apache Tomcat 6.0.16 log". Apr 17, 2011 11:57:57 AM org.apache.catalina.core.ApplicationContext log INFO: Marking
Error in log file
Error in log file  Hi, I AM using Apache tomcat 6.0.16 server... of executing project i get following errors in "Apache Tomcat 6.0.16 log". Apr 17, 2011 11:57:57 AM org.apache.catalina.core.ApplicationContext log INFO: Marking
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
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
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><
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
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
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
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
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
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
Advertisements
 

 

 

DMCA.com