| Home | » | Java | » | Advance Java | » | Java Servlets | » | User Authentication Form | 
|---|
The following is an authentication form, which validates the Login ID and Password keyed in by the user and returns an appropriate page generated by a Servlet code. First of all you will create one table in M.S Access as shown below:
Table Definitions:
 Column Definition: 
 Table Description: 
  | 
Explanation:
When the user submits the login name and password. A check is made in the table for that user name and password. If the user name and password match a single entry a welcome page will be returned, or else access denied page will be returned.
After create table in M.S. Access database now you will create DSN.Test Records:
login[SchoolDemo.mdb]
| Loginname | Password | 
|---|---|
| laura | cath | 
| mirella | mrsbean | 
| bintu | 12345 | 
Following is the source code of the HTML page i.e. Login.html:
The following is the source code for "login.java:
To run the above servlet program , first of all run Apache Tomcat from "Start -> All Programs -> Apache Tomcat 4.0 -> Start Tomcat."
Now compile Java Servlet Program using below command as shown diagram 24.22
| Diagram 24.22 Compile Java Servlet | 
| 
Now, copy "SimpleServlet.class" File and then paste it under "C:/Program Files/Apache Tomcat 4.0/webapps/examples/WEB-INF/classes/" Now, open your any web browser and type html URL where you saved your login.html file. for example:  | 
| Diagram 24.23 Output of Login.html | 
| Diagram 24.23 Output of login.class for a valid username and password | 
| Diagram 24.24 Output of login.class for an invalid username and password | 
Java Servlet Programming
- Creating Java Servlets (Compiling and Running a Java Servlet)
 - Generic and Http Servlets
 - Calling a servlet from within an HTML page
 - Using JDBC In Servlet
 - User Authentication Form using Java Servlet
 





No comments:
Post a Comment