Thursday, 23 February 2017

age validation in servlets wt jntuh

7)A web application that takes name and age from HTML page. If the age is less than 18,it should send a page with “hello <name>,you are not authorized to visit this site” message, where<name> should be replaced with the entered name. 

In order to develop any web application we are required to follow some directory structure.Although you can implement the same concept using IDE like Netbeans or Eclipse, as a beginner it is best to follow manual procedure.
These are the files of src folder:

index.html file

p.java servlet where we actually implement the logic.

 This is the content of WEB-INF folder:

The classes folder consist of compiled java code:

This is the deployment descriptor where we specify the details of servlet mapping.

The application in tomcat is as follows:







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










Wednesday, 15 February 2017

Handling Sessions in Servlets web technologies jntuh

 A web application takes a name as input and on submit it show a hello<name> page where <name> is taken from the request, it shows the start time and  a logout button on clicking this button it should show a logout page with thank you<name> and duration of usage(use session).


To implement the above program in servlets following folder structure is to be followed:

In the src folder all the required files for our application should be kept.

Below snapshots shows u detail of all the programs
home.html

index.html

op.html
res.html

FirstServlet.java


logout.java

After Compilation of your servlets keep the .class files in classes folder as shown below


Following are the images and css files:







The WEB-INF folder structure is as follows



The output of servlet is as follows:










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.