Log-in Valdidation

Log-in Valdidation

how to create login validation in jsp?

View Answers

February 21, 2011 at 4:47 PM

JSP Login Validation

1)login.jsp:

<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
 alert("Enter Username!");
  return false;
}
if(password==""){
 alert("Enter Password!");
  return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>
<%String msg=request.getParameter("msg");
if(msg!=null){
    %>
<label><font color="red"><%=msg%></font></label> 
<%
}
    %>

2)check.jsp:

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

<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
 Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+user+"' and password='"+pass+"'");
int count=0;
          while(rs.next())
          {

                   count++;
          }

                    if(count>0)
          {
            out.println("welcome "+user);
          }
          else
          {
                       response.sendRedirect("login.jsp?msg=Invalid Username or Password");
          }
%>









Related Tutorials/Questions & Answers:
Log-in Valdidation
Log-in Valdidation  how to create login validation in jsp
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
Advertisements
log out
log out  how do i create a log out on a project without it exiting system so it does not reload again
log 4j
log 4j  what is log4j? can you give me clear information about log4j?   Please go through the following link: log4j Tutorials
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
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
ModuleNotFoundError: No module named 'log'
ModuleNotFoundError: No module named 'log'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'log' How to remove the ModuleNotFoundError: No module named 'log' error
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"%> &lt;%@page pageEncoding="UTF-8"%> &lt;%@page import
Version of taglibs>log dependency
List of Version of taglibs>log dependency
Version of co.trikita>log dependency
List of Version of co.trikita>log dependency
Version of com.techshroom>Log dependency
List of Version of com.techshroom>Log dependency
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
Artifacts of com.splinter-log
List of Artifacts of com.splinter-log maven depenency
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
Version of taglibs>log-doc dependency
List of Version of taglibs>log-doc dependency
Version of taglibs>log-examples dependency
List of Version of taglibs>log-examples dependency
Version of com.17jee>e-log dependency
List of Version of com.17jee>e-log dependency
Version of com.amlinv>log-utils dependency
List of Version of com.amlinv>log-utils dependency
Version of com.globalmentor>globalmentor-log dependency
List of Version of com.globalmentor>globalmentor-log dependency
Version of com.identityblitz>log-lib dependency
List of Version of com.identityblitz>log-lib dependency
Version of com.logicartisan>log-indexer dependency
List of Version of com.logicartisan>log-indexer dependency
Version of com.lukekorth>mailable_log dependency
List of Version of com.lukekorth>mailable_log dependency
Version of com.mycila>mycila-log dependency
List of Version of com.mycila>mycila-log dependency
ModuleNotFoundError: No module named 'admin-log'
ModuleNotFoundError: No module named 'admin-log'  Hi, My Python... 'admin-log' How to remove the ModuleNotFoundError: No module named 'admin-log' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'captains-log'
ModuleNotFoundError: No module named 'captains-log'  Hi, My Python... 'captains-log' How to remove the ModuleNotFoundError: No module named 'captains-log' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'clive-log'
ModuleNotFoundError: No module named 'clive-log'  Hi, My Python... 'clive-log' How to remove the ModuleNotFoundError: No module named 'clive-log' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'clive-log'
ModuleNotFoundError: No module named 'clive-log'  Hi, My Python... 'clive-log' How to remove the ModuleNotFoundError: No module named 'clive-log' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'color-log'
ModuleNotFoundError: No module named 'color-log'  Hi, My Python... 'color-log' How to remove the ModuleNotFoundError: No module named 'color-log' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'con-log'
ModuleNotFoundError: No module named 'con-log'  Hi, My Python...-log' How to remove the ModuleNotFoundError: No module named 'con-log... to install padas library. You can install con-log python with following command
ModuleNotFoundError: No module named 'context-log'
ModuleNotFoundError: No module named 'context-log'  Hi, My Python... 'context-log' How to remove the ModuleNotFoundError: No module named 'context-log' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'django-log'
ModuleNotFoundError: No module named 'django-log'  Hi, My Python... 'django-log' How to remove the ModuleNotFoundError: No module named 'django-log' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'eth-log'
ModuleNotFoundError: No module named 'eth-log'  Hi, My Python...-log' How to remove the ModuleNotFoundError: No module named 'eth-log... to install padas library. You can install eth-log python with following command
ModuleNotFoundError: No module named 'eventlet_log'
ModuleNotFoundError: No module named 'eventlet_log'  Hi, My Python... 'eventlet_log' How to remove the ModuleNotFoundError: No module named 'eventlet_log' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'eventlet_log'
ModuleNotFoundError: No module named 'eventlet_log'  Hi, My Python... 'eventlet_log' How to remove the ModuleNotFoundError: No module named 'eventlet_log' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'http-log'
ModuleNotFoundError: No module named 'http-log'  Hi, My Python... 'http-log' How to remove the ModuleNotFoundError: No module named 'http-log... to install padas library. You can install http-log python with following
ModuleNotFoundError: No module named 'log-aggregator'
ModuleNotFoundError: No module named 'log-aggregator'  Hi, My... named 'log-aggregator' How to remove the ModuleNotFoundError: No module named 'log-aggregator' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'log-analyzer'
ModuleNotFoundError: No module named 'log-analyzer'  Hi, My Python... 'log-analyzer' How to remove the ModuleNotFoundError: No module named 'log-analyzer' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'log-annotation'
ModuleNotFoundError: No module named 'log-annotation'  Hi, My... named 'log-annotation' How to remove the ModuleNotFoundError: No module named 'log-annotation' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'log_calls'
ModuleNotFoundError: No module named 'log_calls'  Hi, My Python... 'log_calls' How to remove the ModuleNotFoundError: No module named 'log... have to install padas library. You can install log_calls python with following
ModuleNotFoundError: No module named 'log-color'
ModuleNotFoundError: No module named 'log-color'  Hi, My Python... 'log-color' How to remove the ModuleNotFoundError: No module named 'log... have to install padas library. You can install log-color python with following
ModuleNotFoundError: No module named 'log_colorizer'
ModuleNotFoundError: No module named 'log_colorizer'  Hi, My... 'log_colorizer' How to remove the ModuleNotFoundError: No module named 'log_colorizer' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'log-config'
ModuleNotFoundError: No module named 'log-config'  Hi, My Python... 'log-config' How to remove the ModuleNotFoundError: No module named 'log... have to install padas library. You can install log-config python
ModuleNotFoundError: No module named 'log_deal'
ModuleNotFoundError: No module named 'log_deal'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'log_deal' How to remove the ModuleNotFoundError: No module named 'log_deal
ModuleNotFoundError: No module named 'log-dump'
ModuleNotFoundError: No module named 'log-dump'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'log-dump' How to remove the ModuleNotFoundError: No module named 'log-dump
ModuleNotFoundError: No module named 'log-enricher'
ModuleNotFoundError: No module named 'log-enricher'  Hi, My Python... 'log-enricher' How to remove the ModuleNotFoundError: No module named 'log-enricher' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'log-exec'
ModuleNotFoundError: No module named 'log-exec'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'log-exec' How to remove the ModuleNotFoundError: No module named 'log-exec
ModuleNotFoundError: No module named 'log-ext'
ModuleNotFoundError: No module named 'log-ext'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'log-ext' How to remove the ModuleNotFoundError: No module named 'log-ext
ModuleNotFoundError: No module named 'log-factory'
ModuleNotFoundError: No module named 'log-factory'  Hi, My Python... 'log-factory' How to remove the ModuleNotFoundError: No module named 'log-factory' error? Thanks   Hi, In your python environment

Ads