Share on Google+Share on Google+

2 Answer(s)      8 years ago
Posted in : Java Beginners


View Answers

September 13, 2008 at 10:59 AM

Hi friend,

<title>login application in jsp</title>

<script type="text/javascript">

function validateForm(theForm){


//Please enter username

alert("Please enter User Name.");


return false;

//please enter passward
alert("Please enter Password.");
return false;

return true;


<table border="1" width="400px" bgcolor="pink" cellspacing="0" cellpadding="0">
<td width="100%">
<form method="POST" action="loginAction.jsp" onsubmit="return validateForm(this);">

<h2 align="center"><font color="red">Login Application in JSP</font></h2>
<table border="0" width="350px" cellspacing="2" cellpadding="4">
<td width="50%"><b>User Name:</b></td>
<td width="50%"><input type="text" name="userid" size="20"/> </td>
<td width="50%"><b>Password:</b></td>
<td width="50%"><input type="password" name="password" size="20"/> </td>

<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>


September 13, 2008 at 11:02 AM

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


String userid = request.getParameter("userid");

String password = request.getParameter("password");

Connection con = null;
String url = "jdbc:mysql://";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";

try {

con = DriverManager.getConnection(url+db,userName,pass);

Statement st = con.createStatement();

String strQuery = "select * from login where userid='"+userid+"' and password='"+password+"'";


ResultSet rs = st.executeQuery(strQuery);


if((rs.getString(1).equals("admin")) && (rs.getString(2).equals("admin")))




if((rs.getString(1).equals("user")) && (rs.getString(2).equals("user")))








System.out.println("Connected to the database");


} catch (Exception e) {





Visit for more information.

Thanks & Regards


Related Tutorials/Questions & Answers:
login-password - Java Beginners
login-password  complete code of login-password form then how to connect the bank simulation project?   Hi friend, login...; } if(theForm.password.value==""){ //please enter passward alert("Please enter Password
Login Password Validation iPhone / iPAD
Login Password Validation iPhone / iPAD  HOW TO WRITE A TEST CASE TO SET THE VALIDATION FOR LOGIN AND PASSWORD FIELD IN OBJECTIVE C, IOS.   @implementation LoginViewTests - (void)testPasswordFieldIsNotEmpty
PHP User Authentication Login and password check Tutorial
to the database. $dbname="name"; #Password to verify its you. $dbpass="
password check
password check  how to check sighup passowrd and login password
java - Java Beginners
java  hi, I need the coding for encoding the login password using MD5 algorithm. please help me as soon as possible. Regards, Valarmathi
HQL Query in execute method of Struts2
HQL Query in execute method of Struts2  I am making login page in struts2 and using hibernate . Now I wants to pull user name and password from database and match the login password given by user. But I am not able to fetch
SQL and JSP  1.sql database login and password details along with user name 2.list of employees with all relevant personal details... and password entry box.the user id and password entered will be evaluated
Spring Login Page Error
Spring Login Page Error  Dear Sir/Madam, I used the spring login page code. The index page is working fine. When i try to entry login and password , i am getting the below error: Please help me out in this. Let me know if i
Email sending in jsp - JSP-Servlet
Login Password Back-end coding: = request.getParameter("login"); String password = request.getParameter("password..."); Authenticator auth = new SMTPAuthenticator(login, password
sessions management
sessions management  I have a problem with the session management of my applcation deployed in tomcat. in fact, my application allows only one session to a login / password given. I then add in the database a flag for each user
Java swing
=st.executeQuery("select * from login where username='"+value1+"' and password...(null,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE...Java swing  how to create the login form?   1
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR... java.awt.event.*; class Login { JButton SUBMIT; JLabel label1,label2; final JTextField text1,text2; Login() { final JFrame f=new JFrame("Login Form
Beneficiaries Organizations
will provide a login and password to your students at no cost. Experience certificate... institutions can also be benefited by login us. The bright student will highlight
Swings - Java Beginners
Swings  iam created one login form.iam using mysql database.values also stored in database.after login how to go to another page  Hi Friend...); label2 = new JLabel(); label2.setText("Password:"); text2 = new
login screen - Java Beginners
* FROM login where username='"+value1+"' and password='"+value2... login or password","Error",JOptionPane.ERROR_MESSAGE); text1.setText...login screen  how can code a login screen please send me the code
j2me - Java Beginners
the sensitive information. The information is protected by login and password, which can
j2me project guide - Java Beginners
the sensitive information. The information is protected by login and password
java project - Java Beginners
. The information is protected by login and password, which can be assigned to each single user
java code - Java Beginners
"); } else{ JOptionPane.showMessageDialog(null,"Incorrect login or password... in swing and i want whn we click on start my login page is come next how we... e){ LoginDemo login=new LoginDemo(); login.setVisible(true); login.pack
Create Project SplashScreen - Java Beginners
login where username='"+value1+"' && password='"+value2+"'"); while... that visible only for 1 minute after 1 minute i want to display LogIn form how i...(); window.getContentPane().add(new JLabel("Loading Login Page
Log In Form Validations - Java Beginners
)) { JOptionPane.showMessageDialog(null,"Incorrect login or password","Error...)password if two Jtextfields are blanks i want to show msg blank Username and Password , How I can Do That ,plz Help Me Sir.  Hi Friend, Try
login form
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR...login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components
login form
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error...login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components
page display. In case if user enters incorrect username or password then login...{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error...nextpage  my login form using java awt-swing ..still appearing after
RichFaces: Login & Registration Application:
in front of the user. User fills the login and password information and enters... is not able to login to the application i.e. forget the password, it can get password by clicking the link "Forgot Password?" in the login page itself
Login Form in Java - Java Beginners
= st.executeQuery("SELECT * FROM login where username='"+value1+"' && password='"+value2...Login Form in Java  Hi, In my Project, I am using Java-JDBC-Mysql. Idea is as below. when user give user-id & password, on that he can get
Servlet-JSP population - JSP-Servlet
to validate the login and password. I have got all this right. once he gets logged...Servlet-JSP population  Hi I have a login page which accepts... and password is working fine. my table cartlist has rows in it.I checked
abt java - Java Beginners
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error... authetication ... in this code it take user name password and a user certificate(which... the Login Code in swings. import javax.swing.*; import java.awt.*; import
abt proj - Java Beginners
("Password:"); text2 = new JPasswordField(15); SUBMIT=new JButton("Login... = st.executeQuery("SELECT * FROM login where username='"+value1+"' && password...{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR
java - Java Beginners
and password matches then login and put registry details or say invalid input. i...("Password:"); text2 = new JPasswordField(15); SUBMIT=new JButton("Login...{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE
java date - Java Beginners
,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE); text1.setText...); text1.setBounds(500,50,100,20); label2 = new JLabel(); label2.setText("Password...(500,80,100,20); SUBMIT=new JButton("Login"); SUBMIT.setBounds(500,110,100,20
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null