Log-in Valdidation

Ads

 
 

Share on Google+Share on Google+

Raj
Log-in Valdidation
1 Answer(s)      6 years and 9 months ago
Posted in : JSP-Servlet

how to create login validation in jsp?

Ads
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
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
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 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
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
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
Version of commons-jelly-tags-log>commons-jelly-tags-log dependency
List of Version of commons-jelly-tags-log>commons-jelly-tags-log dependency

Ads

 
Advertisement null

Ads