WTL Assignment No.5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Department of Computer Engineering Subject: Web Technology Laboratory

Expected Date of Completion…………………………………

Actual Date of Completion:………………………….

Assignment No: 5
Title: Design and develop suitable web application using Servlet and MySQL.
Objective:

1. Understand about basic concepts of html, CSS.


2. Understand the basic functionalities of Servlets

Problem Statement
Implement the sample program demonstrating the use of Servlet.
e.g., Create a database table ebookshop (book_id, book_title, book_author, book_price, quantity)
using database like Oracle/MySQL etc. and display (use SQL select query) the table content
using servlet.

Outcomes

1. Develop a dynamic webpage using HTML and Servlet.


2. Write a server-side java application called Servlet to catch the data sent from the client,
process it and show the output.

Software and Hardware requirement


Software:
1. Operating System: Windows 7/8/10/Ubuntu.
2. Browser: Firefox/Google Chrome/ Microsoft Edge etc.
3. Software/Editor : Eclipse
4. Any Operating System
5. JDK 7or later
6. Tomcat 7 or later
Hardware:

7. Processor: Minimum 1 GHz.


8. Ethernet connection (LAN) OR a wireless adapter (Wi-Fi)
9. Hard Drive: Minimum 32 GB.
10. Memory (RAM): Minimum 1 GB
11. Sound card-speakers/camera/microphone (Depending upon website selection)

Theory
Servlet:
A Servlet is a server-side program written in Java. Servlet is a web component that is
deployed on the server for creating dynamic web pages. A Java servlet is a Java program
that extends the capabilities of a server. Although servlets can respond to any types of
requests, they most commonly execute applications hosted on Web servers.

Java Servlets are Java classes run by a web server that has an interpreter that supports the
Java Servlet specification.

Servlets can be created using the packages

• javax.servlet
• javax.servlet.http
Servlet Life Cycle:

o The servlet is initialized by calling the init() method.


o The servlet calls service() method to process a client's request.
o The servlet is terminated by calling the destroy() method.
o Finally, servlet is garbage collected by the garbage collector of the JVM.

Figure: Functions of Servlet

Tools and Techniques


How to configure tomcat server in Eclipse? (One time Requirement)
• If you are using Eclipse IDE first time, you need to configure the tomcat server First.
• For configuring the tomcat server in eclipse IDE,
• click on server’s tab at the bottom side of the IDE -> right click on blank area -> New ->
Servers -> choose tomcat then its version -> next -> click on Browse button -> select the
apache tomcat root folder previous to bin -> next -> addAll -> Finish.
Steps to run servlet in Eclipse

• Create a Dynamic web project.


• Create a servlet.
• Add servlet-api.jar file.
• Run the servlet

Methods

o doGet-
A GET request results from a normal request for a URL or from an HTML form that has no
METHOD specified and it should be handled by the doGet() method.

o doPost-
A POST request results from an HTML form that specifically lists POST as the METHOD and it
should be handled by doPost() method.

Reading HTML Form Data using Servlet:

• getParameter () − You call the request.getParameter() method to get the value of a form
parameter.
• getParameterValues () − Call this method if the parameter appears more than once and
returns multiple values, for example checkbox.
• getParameterNames () − Call this method if you want a complete list of all parameters in
the current request.
Design and Execution Steps
Following steps are used to Create and Execute web applications,

1. Design html and servlet files with an extension of.html and .java.
2. Start the Tomcat Server with port number

Test Cases
All records from the MySQL database should be displayed on the browser using JSP and
HTML.
Conclusion
Hence, we have performed the dynamic web application using Servlet and MySQL.

You might also like