Java Web Application Tutorial for Beginners
Posted by Infocampus HR on January 26th, 2019
Java Web Application
The aim of this text is to produce basic details of various parts in Web Application and the way will we have a tendency to use Servlet and JSP to make our initial java web application.
Web Server and client
Web Server could be software that may method the client request and send the response back to the consumer. As an example, Apache is one in every of the foremost widely used web server. Web Server runs on some physical machine and listens to consumer request on a specific port.
A web client could be a software system that helps in an act with the server. a number of the foremost wide used internet clients area unit Firefox, Google Chrome, Safari etc. once we request one thing from the server (through URL), web client takes care of making an invitation and causation it to the server so parsing the server response and gift it to the user.
HTML and HTTP
Web Server and web client are 2 separate softwares, therefore there ought to be some common language for communication. HTML is that the common language between server and client and stands for the hypertext markup language.
Web server and consumer wants a standard communication protocol, HTTP (HyperText Transfer Protocol) is that the communication protocol between server and consumer. HTTP runs on high of TCP/IP communication protocol.
Some of the vital components of HTTP Request are:
URL is the form of Universal Resource surveyor and it’s used to find the server and resource. Each resource on the net has its own distinctive address.
Why we want Servlet and JSP?
Web servers are sensible for static contents HTML pages however they don’t skills to come up with dynamic content or a way to save knowledge into databases, therefore we want another tool that we will use to come up with dynamic content. There are many programming languages for dynamic content like PHP, Python, and Ruby on Rails, Java Servlets and JSPs.
Java Servlet and JSP are unit server aspect technologies to increase the capability of internet servers by providing support for dynamic response and knowledge persistence.
First Web Application with Servlet and JSP
We will use “Eclipse IDE for Java EE Developers” for making our initial servlet application. Since servlet could be a server aspect technology, we are going to want online instrumentation that supports Servlet technology, therefore we are going to use Apache Tomcat server. It’s terribly simple to set up and that I am an effort that half to you.
For easy development, we will add put together tomcat with Eclipse, it helps in simple readying and running applications.
Tomcat could be a web container, once an invitation is formed from consumer to internet server, it passes the request to internet instrumentation and it’s internet instrumentation job to seek out the right resource to handle the request (servlet or JSP) so use the response from the resource to come up with the response and supply it to internet server. Then the internet server sends the response back to the consumer.
When web container gets the request and if it’s for servlet then container creates 2 Objects HTTPServletRequest and HTTPServletResponse. Then it finds the right servlet supported the URL and creates a thread for the request. Then it invokes the servlet service () technique and supported the HTTP technique service () technique invokes doGet () or doPost () strategies. Servlet strategies generate the dynamic page and write it to respond. Once servlet thread is complete, container converts the response to HTTP response and sends it back to the consumer.
Some of the vital work done by web container is:
Web Application Directory Structure
Java internet Applications area unit prepacked as internet Archive (WAR) and it's an outlined structure. You’ll be able to export on top of dynamic internet project as a WAR file and unfasten it to see the hierarchy.
The web.xml file is that the readying descriptor of the net application and contains the mapping for servlets (prior to three.0), welcome pages, security configurations, session timeout settings etc.
Join us, Infocampus the best Java Training Center Bangalore with 100% Job Assistance. We aware of latest version and industry needs.
Java Training and certification in Bangalore held with most experienced professionals
Call Us: 9738001024
Like it? Share it!
About the AuthorInfocampus HR
Joined: December 10th, 2016
Articles Posted: 792
More by this author