Home Answers Viewqa Java-Beginners JSP entered name and password is valid

 
 


deepti mishra
JSP entered name and password is valid
1 Answer(s)      a year and 3 months ago
Posted in : Java Beginners

HII Im developing a login page using jsp and eclipse,there are two fields username and password,I want to know that how can i check that thw entered name and password is valid,how can i check that from database,plz help me..... Plz send me the codes. Im new in this field..........

View Answers

February 3, 2012 at 12:18 PM


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="http://localhost:8080/examples/Login" 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>

2)Login.java:

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Login extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { 

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try{
        response.setContentType("text/html");
        PrintWriter out=response.getWriter();
        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("/examples/jsp/login.jsp");
          }
    }
    catch (Exception e) {
    e.printStackTrace();
    }
}
}









Related Pages:
"The folder name is not valid" netbeans
"The folder name is not valid" netbeans  "The folder name is not valid" while crating a jsp,html or any page in netbeans
change password - JSP-Servlet
on submit button. after that it should first check that current password entered... then new password must be set into the table masterdb. if the entered password is not in the table masterdb it must show a message that password is not valid
Developing Forgot Password Form
will get the user name and password from the user and forwarded it to the forgot... user login name and password to the user. This form will take the user name... Developing Forgot Password Form   
Password encryption and decryption
;/td><td><input type="password" name="pass"></td></tr>... name=request.getParameter("name"); String password=request.getParameter("pass... INTO user(name,password,address,telno) VALUES(?,?,?,?)"); ps.setString(1,name
to store data entered in html page
use two forms for it 1)for user name,password, submit button 2)for text field,reset and submit botton in form 1 after entering username and password by clicking...to store data entered in html page  i want to a job site
Username password
that checks whether the username and password is valid or not. If the user...("")) { JOptionPane.showMessageDialog(null,"Enter login name or password","Error... with the validation, so that if the username and password match it will continue
Password Controls
determines whether the password entered by the user is correct or not. This whole process is controlled on the server side. Once the password is entered by the user... the password entered by the user is correct or not.   The code of the program
jQuery password validation
) or  unequal  password type entered. With the help of this password... class="left" id="password_again" name...jQuery password Validation : jQuery "equalTo: "#password" "
how to display data from database according to entered value in search field
how to display data from database according to entered value in search...://java.sun.com/jsp/jstl/core"%> <%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%> <%@page import="java.sql.*"%> <%@page
Struts2.2.1 password tag example.
; <s:password name="password" key="...Struts2.2.1 password tag example. In this tutorial, you will see the use of password tag of struts2.2.1. It is a  UI tag in struts framework. It display
Encrypt Password with JSP - JSP-Servlet
to ask you how to make encrypt password with JSP servlet. For example I have... Friend, Try the following code: 1)form.jsp: User Name Password Confirm Password Name Phone Contact 2)encrypt.jsp
How to store data entered by User in JSP page in XML file
How to store data entered by User in JSP page in XML file  How to store data entered by user in JSP page to be saved in XML file.On clicking submit...   JSP store data entered by user into XML file 1)form.jsp: <html>
jsp
JSP entered name and password is valid  HII Im developing a login page using jsp and eclipse,there are two fields username and password,I want to know that how can i check that thw entered name and password is valid,how can i
Struts 2 Url Validator
the given field is a valid URL or not. If the entered value is not a valid URL... field contains a valid URL  String or not. If the entered text is valid...;constant name="struts.enable.DynamicMethodInvocation" value="
how to change password into one jsp to another jsp
how to change password into one jsp to another jsp  i have two jsps in one jsp i give one password and confirm password, in another jsp i want change my password compare with 1st jsp how to write code please give me answer?  
login-password - Java Beginners
login-password  complete code of login-password form then how... application in jsp function validateForm(theForm){ if(theForm.userid.value==""){ //Please enter username alert("Please enter User Name
Send forgot Password through mail - JSP-Servlet
Send forgot Password through mail   hello every one I am designing a admin login page where i am validating the password through file(Example if user Name is Sreenivas and types sree as password i check a file where i
change password servlets - JSP-Interview Questions
change password servlets  hi all, i need the codes to create a change password servlet.  Hi, I dont have the time to write the code. But i... a link for change the password page in that page there should be a three text box
Calling In JavaScript Functions from HTML Form To Validate User Entered Data
Calling In JavaScript Functions from HTML Form To Validate User Entered... and editing my html to call my functions to validate the user entered data...("firstNameTextField").value == "") { alert("Please fill in required First Name
Forgot Password Action,Struts Forgot Password Action class
password action requires user name and passwords same as you had entered during... password action, if the value matches the action sends an email of user name... of ForgotPasswordAction is as follows. At first get the entered data (User Name & Email
Password Field in HTML
;name> :The <name> is used to create name of the field. The password text... on Password <form action=""> First Name: <input type... Password Field in HTML     
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
a jsp file which contains a textbox, name issuedescription. when user types...how to retreive values from MS Access Database based on the values entered in textbox values in jsp file  Hi am new to java. i need to create
JSP code for forget password
JSP code for forget password  I need forget password JSP code.. example http://www.roseindia.net/users/forgotpassword.html
forgot password code in jsp
forgot password code in jsp  forgot password code in jsp   Please visit the following link: http://www.roseindia.net/jsf/richfaces
how to check username & password from database using jsp
. in my oracle10G database already contain table name admin which has name, password. name is amit and password is ddave. so hw could i check whether the username...how to check username & password from database using jsp  Hello, I
Password History - JSP-Servlet
Password History  I am using servlets and in my application i want to maintain password history.It means on password change My application should check previous 5 password so that new password can't be same to 5 old password
forget password
forget password  can i get coding for forgot password in jsp, need using javamail also cannot.. what should i do?? Thx
Change Password - JSP-Servlet
Change Password  Hi all, Please kindly help me with jsp code and explanations to enable me write a change password program. This program will connect to mssql database 2000. Thanks
Forget Password
Forget Password  How i get my forget password through mail?   Please visit the following links: http://www.roseindia.net/jsf/richfaces/ http://www.roseindia.net/jsf/richfaces/developing-jsp-files.shtml
Password validation
;input type="password" name="current" ></td></tr> <tr><td>New Password</td><td><input type="password" name="new"><...;input type="password" name="confirm"></td></tr> <tr><
Password validation
;Current Password</td><td><input type="password" name="current...;<input type="password" name="new"></td></tr> <tr><td>Confirm Password</td><td><input type="password" name="confirm
Password validation
;Current Password</td><td><input type="password" name="current...;<input type="password" name="new"></td></tr> <tr><td>Confirm Password</td><td><input type="password" name="confirm
Password validation
;Current Password</td><td><input type="password" name="current...;<input type="password" name="new"></td></tr> <tr><td>Confirm Password</td><td><input type="password" name="confirm
Password validation
;Current Password</td><td><input type="password" name="current...;<input type="password" name="new"></td></tr> <tr><td>Confirm Password</td><td><input type="password" name="confirm
Password Tag (Form Tag) Example
;Enter Passwordname="password" size="10" ...Password Tag (Form Tag) Example       In this section, we are going to describe the password tag. The password tag
jsp.....
jsp.....  1..login screen->user-id and password will be entered and save has to be validated against database corresponding table.on successful... for search criteria like name and dob will be asked.on entering the detail,data
Decrypt an encrypted password in JSP
Decrypt an encrypted password in JSP   How to decrypt an encrypted password and store in database ? Her is my code that i have done for encryption..."); > String > pass=request.getParameter("password"); > String > cpass
Spring Security Password Hashing
; <user name="admin" password="...;password' name='j_password' /> </td> </tr> <tr>...Spring Security Password Hashing In this section, you will learn about
jsp login code ... when username , drop down box and password is correct
jsp login code ... when username , drop down box and password is correct  i need a jsp code for login.... when username password and dropdown box... type="password" name="pass"></td></tr> <tr><td>Select
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in whic i should select the company name...;input type="password" name="pass"></td></tr> <tr><td>
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct... Password!"); return false; } return true; } </script> <form name="form..." name="user"></td></tr> <tr><td>Password:</td>
To Retain the values entered in the text box after submit in jsp page
To Retain the values entered in the text box after submit in jsp page   i am working on a jsp pge which has many text boxes and one dynamic drop... given all those. Now my problem is how can i retain those values entered in box
Forgot Password of Application
Forgot Password of Application  Forgot Password of Application through servlet and jsp
decrypt a password in servlet
decrypt a password in servlet  hi i want to decrypt the password.when user log in take the encrypted password and decrypt .then check the password with user entered and log in to the system
JSTL: Form Action Text Field
to retrieve the value we have entered in the jsp form.  Firstly we are going to make a simple jsp form page in which there are two textfields, one is for user name...; <td> <input type="password" name="pwd"/>
jsp
jsp  how to create a table in oracle using jsp and the table name is entered in text feild of jsp page
Random Creation of password
details in it.When clicking on the submit button it gives me a password .....Details and the password is saved in the database....The password has to be encrypted and then send to the database.....I am using jsp as my front end and java
Forgot Password Screen of Application
his/her password is sent on his email id. Valid User id:  Email is sent... Forgot Password Screen of Application       Forgot Password Screen our web application allows
Name Displaying - JSP-Servlet
Name Displaying  Dear Sir, Please any one help me......... when i enter some value in text that value is already in database dispaly the alert...( ); } User Name
Authentication of password - Swing AWT
eraser.stopMasking(); // return the password entered by the user... = PasswordField.readPassword("Enter password: "); System.out.println("The password entered...Authentication of password  System level authentication of password

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.