Slot 1 - Introduction Java Web Application
Slot 1 - Introduction Java Web Application
Describe the role of HTTP protocol and its methods used for accessing Web pages
❖ Web Application
❑ Runs at a remote location.
❖ Web Application:
❑ Is a software application that runs on a Web server.
❑ Consists of Web pages which can be static and dynamic.
❖ Static Web pages:
❑ Are created using Web technologies such as HyperText Markup Language
(HTML), Cascading Style Sheet (CSS), and JavaScript.
❖ Dynamic Web pages:
❑ Server-side programs are used to achieve dynamic functionalities on Web
pages.
❑ Provide interactivity with the users.
Users accessing the Web pages on the World Wide Web (WWW) are
referred to as Web clients.
clubbed together.
❑ Figure shows the one-tier architecture.
❖ Two-tier architecture
❑ Code related to data access logic is separated from the other two
components.
❑ Any interaction with data tier will be done through business tier.
❑ Business tier acts as an interface between the data tier and the
presentation tier.
❑ Figure shows the three-tier architecture.
❖ N-tier architecture
❑ Layers are further subdivided for ease of functioning.
❑ Business layer and application layer are separated reducing the number of
client.
❑ The Accept header element provides information on what media types
❖ PUT
❑ Used to request the server to store the data enclosed in the HTTP
request URL.
❖ OPTIONS
❑ Can be used to query the server on the methods supported for a
❑ Useful when the request sent to the server reaches through the proxies.
❑ Server-side JavaScript
❑ PHP
❑ Java Servlets
❖ Disadvantages of CGI:
❑ Reduced efficiency - Number of processes that can be executed by a Web server is
limited to each server.
❑ Reloading Perl interpreter - Each time the server receives a request, the Perl
interpreter needs to be reloaded. This reduces the efficiency of the server.
❖ Servlets are written using Java language, which makes extensive use of Java
API. The merits of servlets are:
❑ Enhanced efficiency - Servlet is required to be executed only once at the
Java along with HTML implemented within the Java code, which increases
the ease of use.
❑ Powerful - The usage of Java APIs makes the Servlets a powerful server-
Compile the Web application components and helper classes referenced by the
components.
http://localhost:8080/WebApp/page/index.html.
❑ Thus, the context root of the deployed application is the /WebApp.
❖ lib directory
❑ Library JAR files used by the application are stored within the WEB-
INF/lib directory.
❑ Example: Database driver files.
❖ tags directory
❑ Contains tag files, which provide implementation for custom tags.
❖ Servlet 3.0 has also introduced a new feature called Web fragments.
❖ Web fragment is the mechanism that:
❑ Include deployment descriptor information which is specific to a library.
❑ Helps to segregate the unrelated information from the main deployment
information.
❑ Is stored in the folder META-INF\web-fragment.xml of the Web
application directory structure.
Demo
Summary
A Web application is a software application that runs on a Web server. The Web
application basically has three components: the presentation layer, the application
layer, also known as business layer, and the data access layer.
The most common technologies for communication on the Web are HTML and HTTP.
HTML is a presentation language which enables Web designer to create visually
attractive Web pages.
The requests and responses sent to a Web application from one computer to another
computer are sent using HTTP. HTTP does not store any connection information about the
page and hence, it is referred to as a stateless protocol.
The HTTP request messages uses the HTTP methods for transmitting request data over the Web.
Java Web application comprises servlets, JSP pages, images, HTML files, JavaBeans, Applets, and
Java classes.
The Web applications are packaged in the .war file which allows the content of the Web application are
accessed from the application’s context root.
A deployment descriptor describes how the Web application should be deployed. It is written using XML with
name web.xml and placed under the WEB-INF folder, that is, WEB-INF/web.xml.
Java Web applications are developed in NetBeans IDE which provides fully-integrated