Log-in Valdidation

Ads
 

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");
          }
%>

Ads









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
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 '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 'bae_log'
ModuleNotFoundError: No module named 'bae_log'  Hi, My Python..._log' How to remove the ModuleNotFoundError: No module named 'bae_log... to install padas library. You can install bae_log python with following command
ModuleNotFoundError: No module named 'bigtree-log'
ModuleNotFoundError: No module named 'bigtree-log'  Hi, My Python... 'bigtree-log' How to remove the ModuleNotFoundError: No module named 'bigtree-log' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'bluelens-log'
ModuleNotFoundError: No module named 'bluelens-log'  Hi, My Python... 'bluelens-log' How to remove the ModuleNotFoundError: No module named 'bluelens-log' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'bottle-log'
ModuleNotFoundError: No module named 'bottle-log'  Hi, My Python... 'bottle-log' How to remove the ModuleNotFoundError: No module named 'bottle-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

Ads