Showing posts with label servlets. Show all posts
Showing posts with label servlets. Show all posts

Sunday, 12 March 2017

WTLAB program to implement PASSWORD MISMATCH using servlets


A web application for implementation: The user is first served a login page which takes user’s name and password. After submitting the details the server checks these values against the data from a database and takes following decisions. If name and password matches, serves a welcome page with user’s full name. If name matches and password doesn’t match, then serves “password mismatch “page. 
If name is not found in database serves a registration page where user’s full name is asked and on submitting the details are stored in database

To implement the above program using servlets all u require is :
1.Tomcat container
2.Notepad
3.Browser
4.Connector.jar file which is to be placed in tomcat's lib folder

Initially u have to create a folder structure as follows:

As u can see in the above image the html files are kept outside.It is your choice to keep it in src folder or not.
The login.html file consist of 


 Focus on the action attribute in the above form, the url port number may change based on ur tomcats setting.
The regi.html file consist of 


The WEB-INF directory consists of 


 The classes folder may consist of  all the java files and .class files as follows

The servlet process.java has following set of instructions:

The servlet regi.java has following



Open mysql and create the required database and tables as follows





After writing the java files u have to compile it in cmd prompt


Once compiled move out of classes folder and type web.xml contents

Open Tomcat and type the url of ur project

Initially i assumed no user information is present in the database so u will be redirected to registration page.
After registration u will be asked to login ,These are the details of the registered user in mysql.

Once u specify the password and username u will get successfull response.

If by mistake u forgot and specified wrong password u will get the following message.

This is it.Same logic we can implement in jsp and php as well.U can also use framesets for this program just like i discussed in my previous posts.Do not stick to same program try to use either bootstrap or manual css for enhancing its looks.

Hope this post is useful to all who are watching right now.










Friday, 17 February 2017

User authentication in Servlets


A user validation web application, where the user submits the login name and password to the server. The name and password are checked against the data already available in Database and if the data matches, a successful login page is returned. Otherwise a failure message is shown to the user. 

All u need is: 1. Mysql Database
                       2.Its connector.jar file
                       3.Notepad
                       4.Tomcat Server

Let's first create the folder structure in web-apps of tomcat container:






Mysql database file creation




Now we have to write the src code:

1. logp.java
2. Welcome.java
3. home.html



After Compiling the java programs place it in classes folder as shown below:

Place mysql-connector.jar file in lib folder


web.xml file is shown below:


Below image shows u the application uploaded in tomcat:


 This is the output in tomcat










Sunday, 12 February 2017

wt calculator program using servlets

CALCULATOR PROGRAM
AIM: To implement calculator operations using servlets and access the results stored in database

The below image shows the directory structure to be followed in tomcat server




After compiling java programs place class files in classes folder


To use database we require mysqlconnector.jar file which should be placed in lib folder.


Below is the deployment descriptor which gives the details about servlet,servlet class,url-pattern 



All the source code file are kept in src folder.


This is the main page where we are creating frames and accessing servlets in it.


The File which gives the details about left frame.

Calculator html file.Notice the target attribute here.

The file for another frame where results are showed.

This is the calculator servlet.


Calculator HTML file.

Calculator results page.


Calculator db servlet.



Tomcat Manager page.U can see the deployed calc project.


Calculator index page running on tomcat server.




Calculator table in Database.