Tutorial

Java Web Application Tutorial for Beginners

Published on August 3, 2022
author

Pankaj

Java Web Application Tutorial for Beginners

Java Web Application is used to create dynamic websites. Java provides support for web application through Servlets and JSPs. We can create a website with static HTML pages but when we want information to be dynamic, we need web application.

Java Web Application

The aim of this article is to provide basic details of different components in Web Application and how can we use Servlet and JSP to create our first java web application.

  1. Web Server and Client
  2. HTML and HTTP
  3. Understanding URL
  4. Why we need Servlet and JSPs?
  5. First Web Application with Servlet and JSP
  6. Web Container
  7. Web Application Directory Structure
  8. Deployment Descriptor

Web Server and Client

Web Server is a software that can process the client request and send the response back to the client. For example, Apache is one of the most widely used web servers. Web Server runs on some physical machine and listens to client request on a specific port. A web client is a software that helps in communicating with the server. Some of the most widely used web clients are Firefox, Google Chrome, Safari, etc. When we request something from the server (through URL), the web client takes care of creating a request and sending it to the server and then parsing the server response and present it to the user.

HTML and HTTP

Web Server and Web Client are two separate softwares, so there should be some common language for communication. HTML is the common language between server and client and stands for HyperText Markup Language. Web server and client needs a common communication protocol, HTTP (HyperText Transfer Protocol) is the communication protocol between server and client. HTTP runs on top of TCP/IP communication protocol. Some of the important parts of the HTTP Request are:

  • HTTP Method - action to be performed, usually GET, POST, PUT etc.
  • URL - Page to access
  • Form Parameters - similar to arguments in a java method, for example user,password details from login page.

Sample HTTP Request:

GET /FirstServletProject/jsps/hello.jsp HTTP/1.1
Host: localhost:8080
Cache-Control: no-cache

Some of the important parts of HTTP Response are:

  • Status Code - an integer to indicate whether the request was success or not. Some of the well known status codes are 200 for success, 404 for Not Found and 403 for Access Forbidden.
  • Content Type - text, html, image, pdf etc. Also known as MIME type
  • Content - actual data that is rendered by client and shown to user.

Sample HTTP Response:

200 OK
Date: Wed, 07 Aug 2013 19:55:50 GMT
Server: Apache-Coyote/1.1
Content-Length: 309
Content-Type: text/html;charset=US-ASCII

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Hello</title>
</head>
<body>
<h2>Hi There!</h2>
<br>
<h3>Date=Wed Aug 07 12:57:55 PDT 2013
</h3>
</body>
</html>

MIME Type or Content Type: If you see above sample HTTP response header, it contains tag “Content-Type”. It’s also called MIME type and server sends it to the client to let them know the kind of data it’s sending. It helps the client in rendering the data for the user. Some of the most used mime types are text/html, text/xml, application/xml etc.

Understanding URL

URL is the acronym of Universal Resource Locator and it’s used to locate the server and resource. Every resource on the web has its own unique address. Let’s see parts of the URL with an example. https://localhost:8080/FirstServletProject/jsps/hello.jsp https:// - This is the first part of URL and provides the communication protocol to be used in server-client communication. localhost - The unique address of the server, most of the times it’s the hostname of the server that maps to unique IP address. Sometimes multiple hostnames point to same IP addresses and web server virtual host takes care of sending a request to the particular server instance. 8080 - This is the port on which server is listening, it’s optional and if we don’t provide it in URL then request goes to the default port of the protocol. Port numbers 0 to 1023 are reserved ports for well-known services, for example, 80 for HTTP, 443 for HTTPS, 21 for FTP, etc. FirstServletProject/jsps/hello.jsp - Resource requested from server. It can be static html, pdf, JSP, servlets, PHP etc.

Why we need Servlet and JSPs?

Web servers are good for static contents HTML pages but they don’t know how to generate dynamic content or how to save data into databases, so we need another tool that we can use to generate dynamic content. There are several programming languages for dynamic content like PHP, Python, Ruby on Rails, Java Servlets and JSPs. Java Servlet and JSPs are server-side technologies to extend the capability of web servers by providing support for dynamic response and data persistence.

Java Web Development

First Web Application with Servlet and JSP

We will use “Eclipse IDE for Java EE Developers” for creating our first servlet application. Since servlet is a server-side technology, we will need a web container that supports Servlet technology, so we will use the Apache Tomcat server. It’s very easy to set up and I am leaving that part to yourself. For ease of development, we can add configure Tomcat with Eclipse, it helps in easy deployment and running applications. Go to Eclipse Preference and select Server Runtime Environments and select the version of your tomcat server, mine is Tomcat 7. Eclipse-with-Tomcat Provide the apache tomcat directory location and JRE information to add the runtime environment. Now go to the Servers view and create a new server like below image pointing to the above-added runtime environment. Eclipse-New-Server-Tomcat Note: If Servers tab is not visible, then you can select Window > Show View > Servers so that it will be visible in Eclipse window. Try stopping and starting the server to make sure it’s working fine. If you have already started the server from the terminal, then you will have to stop it from the terminal and then start it from Eclipse else it won’t work perfectly. Now we are ready with our setup to create the first servlet and run it on tomcat server. Select File > New > Dynamic Web Project and use below image to provide runtime as the server we added in last step and module version as 3.0 to create our servlet using Servlet 3.0 specs. First-Servlet-dynamic-web-project You can directly click the Finish button to create the project or you can click on Next buttons to check for other options. Now select File > New > Servlet and use below image to create our first servlet. Again we can click finish or we can check other options through the next button. first-servlet When we click on the Finish button, it generates our Servlet skeleton code, so we don’t need to type in all the different methods and imports in servlet and saves us time. Now we will add some HTML with dynamic data code in doGet() method that will be invoked for HTTP GET request. Our first servlet looks like below.

package com.journaldev.first;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class FirstServlet
 */
@WebServlet(description = "My First Servlet", urlPatterns = { "/FirstServlet" , "/FirstServlet.do"}, initParams = {@WebInitParam(name="id",value="1"),@WebInitParam(name="name",value="pankaj")})
public class FirstServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	public static final String HTML_START="<html><body>";
	public static final String HTML_END="</body></html>";
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FirstServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		Date date = new Date();
		out.println(HTML_START + "<h2>Hi There!</h2><br/><h3>Date="+date +"</h3>"+HTML_END);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}

Before Servlet 3, we need to provide the url pattern information in web application deployment descriptor but servlet 3.0 uses java annotations that is easy to understand and chances of errors are less. Now chose Run > Run on Server option from servlet editor window and use below images for the options. servlet-eclipse-server servlet-eclipse-server-webapps After clicking finish, the browser will open in Eclipse and we get following HTML page. first-servlet-run You can refresh it to check that Date is dynamic and keeps on changing, you can open it outside of Eclipse also in any other browser. So servlet is used to generate HTML and send it in response, if you will look into the doGet() implementation, we are actually creating an HTML document as writing it in response PrintWriter object and we are adding dynamic information where we need it. It’s good for a start but if the response is huge with a lot of dynamic data, it’s error-prone and hard to read and maintain. This is the primary reason for the introduction of JSPs. JSP is also server-side technology and it’s like HTML with additional features to add dynamic content where we need it. JSPs are good for presentation because it’s easy to write because it’s like HTML. Here is our first JSP program that does the same thing as the above servlet.

<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Hello</title>
</head>
<body>
<h2>Hi There!</h2>
<br>
<h3>Date=<%= new Date() %>
</h3>
</body>
</html>

If we run above JSP, we get output like below image. first-jsp-run The final project hierarchy looks like below image in Eclipse. project-hierarchy-servlet

Download FirstServlet Project

Download Servlet Hello World Example Project

We will look into Servlets and JSPs in more detail in future posts but before concluding this post, we should have a good understanding of some of the aspects of Java web applications.

Web Container

Tomcat is a web container, when a request is made from Client to web server, it passes the request to web container and it’s web container job to find the correct resource to handle the request (servlet or JSP) and then use the response from the resource to generate the response and provide it to web server. Then the webserver sends the response back to the client. When web container gets the request and if it’s for servlet then container creates two Objects HTTPServletRequest and HTTPServletResponse. Then it finds the correct servlet based on the URL and creates a thread for the request. Then it invokes the servlet service() method and based on the HTTP method service() method invokes doGet() or doPost() methods. Servlet methods generate the dynamic page and write it to the response. Once servlet thread is complete, the container converts the response to HTTP response and send it back to the client. Some of the important work done by web container are:

  • Communication Support - Container provides easy way of communication between web server and the servlets and JSPs. Because of the container, we don’t need to build a server socket to listen for any request from the webserver, parse the request and generate a response. All these important and complex tasks are done by container and all we need to focus is on our business logic for our applications.
  • Lifecycle and Resource Management - Container takes care of managing the life cycle of servlet. The container takes care of loading the servlets into memory, initializing servlets, invoking servlet methods and destroying them. The container also provides utility like JNDI for resource pooling and management.
  • Multithreading Support - Container creates a new thread for every request to the servlet and when it’s processed the thread dies. So servlets are not initialized for each request and save time and memory.
  • JSP Support - JSPs doesn’t look like normal java classes and web container provides support for JSP. Every JSP in the application is compiled by container and converted to Servlet and then container manages them like other servlets.
  • Miscellaneous Task - Web container manages the resource pool, does memory optimizations, run garbage collector, provides security configurations, support for multiple applications, hot deployment and several other tasks behind the scene that makes our life easier.

Web Application Directory Structure

Java Web Applications are packaged as Web Archive (WAR) and it has a defined structure. You can export above dynamic web project as WAR file and unzip it to check the hierarchy. It will be something like below image. WAR-directory-structure

Deployment Descriptor

web.xml file is the deployment descriptor of the web application and contains a mapping for servlets (prior to 3.0), welcome pages, security configurations, session timeout settings, etc. Thats all for the java web application startup tutorial, we will explore Servlets and JSPs more in future posts. Update: Next tutorial in this series is Java Servlets Tutorial

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Category:
Tutorial

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
JournalDev
DigitalOcean Employee
DigitalOcean Employee badge
August 9, 2013

very nice tutorial, i was under impression that I know all about web applications but I learned something new today. I am still using servlet 2.5 but its nice to see annotations in 3.0 looking forward for future posts, G+1 from my side. :)

- Amit

JournalDev
DigitalOcean Employee
DigitalOcean Employee badge
February 5, 2015

I really enjoyed it thanks alot

- kavousi

    JournalDev
    DigitalOcean Employee
    DigitalOcean Employee badge
    August 9, 2013

    You said HTTP is the common language between server and client and stands for Hyper Text Markup Language ??? I am reading correct ? I mean it must be HTML in place of HTTP. Please let me know if any errors. By the way the article is very nice. Would love to read more about Apache and tomcat practical questions as well as answers to the questions such as where is init method ? what code and class is executed first when first request is received by servlet? Please post informative articles on these subjects too. Also allow people to download the sample code for reference.

    - Aditya

    JournalDev
    DigitalOcean Employee
    DigitalOcean Employee badge
    August 10, 2013

    Thanks Aditya for pointing out the type, mistakenly I wrote HTTP instead of HTML. Corrected the article and next article is about Servlets in more detail. Regarding downloading source code, you can easily copy paste it into Eclipse IDE. Its better for learning than just download the project and run it.

    - Pankaj

      JournalDev
      DigitalOcean Employee
      DigitalOcean Employee badge
      August 19, 2013

      It is outdated to reference Java Enterprise as J2ee, nowdays it is common sense to use Java EE X where X stands for the version 5 or above(eg. Java EE 5). I also doubt that the annotations introduced with EJB 3.0 relate to prior versions of Java EE ;)

      - corsibu

        JournalDev
        DigitalOcean Employee
        DigitalOcean Employee badge
        September 6, 2013

        I savor, lead to I discovered just what I used to be looking for. You’ve ended my 4 day long hunt! God Bless you man. Have a nice day. Bye

        - bagsh

          JournalDev
          DigitalOcean Employee
          DigitalOcean Employee badge
          October 1, 2013

          Can you tell me the why GenericServlet they made as an abstract class Why can’t be interface.

          - Siddu

            JournalDev
            DigitalOcean Employee
            DigitalOcean Employee badge
            January 5, 2014

            Thanks for the quick overview. That was very helpful. I was wondering if you have another overview of how a dynamic web project can be made into a maven dynamic web project?

            - Vash2007

            JournalDev
            DigitalOcean Employee
            DigitalOcean Employee badge
            January 6, 2014

            I think you need to create “Dynamic Web Project” first and then from the project menu, Configure> “Convert to Maven Project” option to convert it to Maven Project.

            - Pankaj

              JournalDev
              DigitalOcean Employee
              DigitalOcean Employee badge
              April 15, 2014

              I m getting below error after running above code please help HTTP Status 404 - /

              - Abhinav Chawan

              JournalDev
              DigitalOcean Employee
              DigitalOcean Employee badge
              April 15, 2014

              check the URL its hitting, 404 means resource not found.

              - Pankaj

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                April 29, 2014

                I needed to import this, wasn’t mentioned in the code import javax.servlet.annotation.WebInitParam; it worked after that

                - Lucian

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                April 29, 2014

                If you are using a class and it’s not imported, you will get compile time error. Your application won’t event build and deploy without fixing it, so I dont think this is the problem for Abhinav. Also it’s mentioned in the above code.

                - Pankaj

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                May 5, 2014

                Hi friends, I’m trying to switchover my career from IT support to java programmer. I have very good knowledge in core java. I’m trying to learn jsp & servlet. But it is very much confusing. If u have any document to emplain jsp& servlet in simple manner, kinldy share… If u can explain jsp concepts with a demo prject, that will be very helpful for my future/career. Thanks, Kupi.

                - kupi

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                May 5, 2014

                Go through the online tutorials and there are so many good books out there.

                - Pankaj

                  JournalDev
                  DigitalOcean Employee
                  DigitalOcean Employee badge
                  June 2, 2014

                  Yes Lucian is right , I was also facing same . Pankaj it’s not complaining for this at build time, may be you need to update this example.

                  - Manish

                  JournalDev
                  DigitalOcean Employee
                  DigitalOcean Employee badge
                  June 2, 2014

                  Hi Manish, As mentioned in above comment, if you won’t have import for WebInitParam, then you will get compile time error, there is no way the code will compile fine. Also in above code, import statement is present. So I am not sure what do you mean by updating the example.

                  - Pankaj

                    JournalDev
                    DigitalOcean Employee
                    DigitalOcean Employee badge
                    April 25, 2014

                    Thanks for this tutorial, great stuff!

                    - Mo Fin

                      JournalDev
                      DigitalOcean Employee
                      DigitalOcean Employee badge
                      June 5, 2014

                      Great to see you are running & accessing servlet from localhost. I succeeded in that. No how can I run same HelloWorld servlet on remote linux server with static IP. I have root access to remote linux machine with static IP. Please help!

                      - Satyabrata Mohanty

                      JournalDev
                      DigitalOcean Employee
                      DigitalOcean Employee badge
                      June 5, 2014

                      Change localhost to the machine IP, thats it.

                      - Pankaj

                        JournalDev
                        DigitalOcean Employee
                        DigitalOcean Employee badge
                        June 19, 2014

                        I am getting an error that constructor Date is undefined.

                        - JACOB JOY

                          JournalDev
                          DigitalOcean Employee
                          DigitalOcean Employee badge
                          June 21, 2014

                          Hi Pankaj, I have a special requirement in my project where I want to establish navigation between 2 different web apps. I have web app1 which will be submitting a transaction. But before this transaction actually gets submitted, I need to call a different web app2 that will authenticate some Knowledge Based Questions. Once successful I need to resume submisstion of transaction and control should come back to web app1…But if authentication fails control should again come back to web app1 and instead of submitin gthe transaction I need to handle it other way. Kindly suggest with some steps and code example. I am using java and Spring MVC. Thanks, Manish

                          - Aravind

                            JournalDev
                            DigitalOcean Employee
                            DigitalOcean Employee badge
                            July 20, 2014

                            Nicely done Pankaj !

                            - Sri

                              JournalDev
                              DigitalOcean Employee
                              DigitalOcean Employee badge
                              August 2, 2014

                              pankaj i like your help to the people who want knowledge you are nice one god bless you. ok my problem is me i need to develop software of internet tv as my project so java is enough in my project or what other programming language which are better for my project like html and java script i need your help teacher

                              - sabin elias morris

                                JournalDev
                                DigitalOcean Employee
                                DigitalOcean Employee badge
                                August 28, 2014

                                Hi Pankaj, It is really good and useful article. Good that you have taken up the latest servlet3.0 examples. Really helpful.

                                - Kishore

                                  JournalDev
                                  DigitalOcean Employee
                                  DigitalOcean Employee badge
                                  September 6, 2014

                                  Hi Sir, Can you please make all the tutorials and interview questions as downloadable “PDFf” files then it will be very useful. Thanks.

                                  - stalin

                                    JournalDev
                                    DigitalOcean Employee
                                    DigitalOcean Employee badge
                                    September 13, 2014

                                    what if your version of Apache tomcat is not listed in Eclipe–>Window–>Preferences–>Server–>RTE–>Add–>Apache? Thanks,

                                    - Don

                                    JournalDev
                                    DigitalOcean Employee
                                    DigitalOcean Employee badge
                                    September 13, 2014

                                    Try to use the nearest version from the list, it should work.

                                    - Pankaj

                                      JournalDev
                                      DigitalOcean Employee
                                      DigitalOcean Employee badge
                                      October 19, 2014

                                      Nice tutorial but you shouldn’t have to worry about these types of things anymore… it’s time consuming. Use the Jigy Generator to create your project and everything will be completely configured for you. Jigy Generator reverse engineers your database to create all your DAO’s, domain objects and validators for you. Plus you have certain things that just work out of the box like login, authentication, file upload etc. You can download the project at www.getjigy.com

                                      - right_now

                                      JournalDev
                                      DigitalOcean Employee
                                      DigitalOcean Employee badge
                                      December 28, 2014

                                      I am facing challenge in generating eclipse project using Jigy Generator 1.0.4. After providing the mandatory information on the create project page, the download page never appears. The orbiting hour glass overlay never goes away. (Sidenote: I checked using firebug, the HTTP request received a response “Success”.)

                                      - Harshad

                                        JournalDev
                                        DigitalOcean Employee
                                        DigitalOcean Employee badge
                                        November 3, 2014

                                        I’m getting this error: HTTP Status 405 - HTTP method GET is not supported by this URL -------------------------------------------------------------------------------- type Status report message HTTP method GET is not supported by this URL description The specified HTTP method is not allowed for the requested resource. -------------------------------------------------------------------------------- Apache Tomcat/7.0.47

                                        - misaochan

                                          JournalDev
                                          DigitalOcean Employee
                                          DigitalOcean Employee badge
                                          November 12, 2014

                                          Nice Tutorials, but if you want to clear your concept click on the like

                                          - Mayyank

                                            JournalDev
                                            DigitalOcean Employee
                                            DigitalOcean Employee badge
                                            November 26, 2014

                                            I am getting this error. Please help. WebInitParam cannot be resolved to a type

                                            - chaitra

                                            JournalDev
                                            DigitalOcean Employee
                                            DigitalOcean Employee badge
                                            November 26, 2014

                                            Make sure your servlet container is Servlet3 complaint, use tomcat-7 or above versions.

                                            - Pankaj

                                              JournalDev
                                              DigitalOcean Employee
                                              DigitalOcean Employee badge
                                              December 25, 2014

                                              GREAT TUTORIAL FOR STARTER…

                                              - SATPAL

                                                JournalDev
                                                DigitalOcean Employee
                                                DigitalOcean Employee badge
                                                December 30, 2014

                                                I’m new to Java / Web technologies. After searching several web sites i found this article is very simple and easy to follow. Thanks a lot.

                                                - Suren

                                                  JournalDev
                                                  DigitalOcean Employee
                                                  DigitalOcean Employee badge
                                                  January 14, 2015

                                                  HTTP Status 404 - /FirstServletProject/ -------------------------------------------------------------------------------- type Status report message /FirstServletProject/ description The requested resource is not available. -------------------------------------------------------------------------------- Apache Tomcat/7.0.55 This is the error I am getting. Could you please provide a possible solution?

                                                  - Shreya

                                                  JournalDev
                                                  DigitalOcean Employee
                                                  DigitalOcean Employee badge
                                                  January 15, 2015

                                                  Your web app servlet context is something else

                                                  - Pankaj

                                                  JournalDev
                                                  DigitalOcean Employee
                                                  DigitalOcean Employee badge
                                                  April 17, 2015

                                                  I am also getting the same error can you please tell the steps to resolve this issue.

                                                  - Akshay

                                                  JournalDev
                                                  DigitalOcean Employee
                                                  DigitalOcean Employee badge
                                                  September 13, 2015

                                                  If you are using windows/eclipse change the link to FirstServlet.java in annotation of the Servlet class.

                                                  - Haider

                                                  JournalDev
                                                  DigitalOcean Employee
                                                  DigitalOcean Employee badge
                                                  January 3, 2017

                                                  where should I make the change exactly?? Thanks.

                                                  - yashwanth nemani

                                                    JournalDev
                                                    DigitalOcean Employee
                                                    DigitalOcean Employee badge
                                                    May 27, 2015

                                                    The issue is that the author called the project FirstServletProject in the create new dynamic web project image, but coded it as FirstServlet

                                                    - Brian

                                                      JournalDev
                                                      DigitalOcean Employee
                                                      DigitalOcean Employee badge
                                                      January 24, 2015

                                                      vey nice …simple

                                                      - Ravi Sindhe

                                                        JournalDev
                                                        DigitalOcean Employee
                                                        DigitalOcean Employee badge
                                                        January 27, 2015

                                                        nice tutorial… It truely helped me

                                                        - Java Belazy

                                                          JournalDev
                                                          DigitalOcean Employee
                                                          DigitalOcean Employee badge
                                                          January 27, 2015

                                                          Hi pankaj, How will we use application.resources to our web application?

                                                          - Java Belazy

                                                            JournalDev
                                                            DigitalOcean Employee
                                                            DigitalOcean Employee badge
                                                            January 29, 2015

                                                            Very nice Article.Simple language and easy to grasp.

                                                            - Arshi

                                                              JournalDev
                                                              DigitalOcean Employee
                                                              DigitalOcean Employee badge
                                                              February 8, 2015

                                                              thank u very much

                                                              - Gaurav Jagtap

                                                                JournalDev
                                                                DigitalOcean Employee
                                                                DigitalOcean Employee badge
                                                                March 6, 2015

                                                                It is really great and easy to understand . I got so many things .I wish you my best , Dear friend.

                                                                - Ali

                                                                  JournalDev
                                                                  DigitalOcean Employee
                                                                  DigitalOcean Employee badge
                                                                  March 9, 2015

                                                                  Hello Pankaj, I am very new to this technologies and I am keen to learn it more so please share your more blogs for web application. I would be really glad.

                                                                  - Ankita

                                                                    JournalDev
                                                                    DigitalOcean Employee
                                                                    DigitalOcean Employee badge
                                                                    March 9, 2015

                                                                    I was blind but now I see! Thank you for clear and transparent information, nicely served :)

                                                                    - Poozone

                                                                      JournalDev
                                                                      DigitalOcean Employee
                                                                      DigitalOcean Employee badge
                                                                      March 10, 2015

                                                                      Hi Pankaj, For the Date application which you have created, I want to give one URL or Link using which any person can access this application. So how can I provide a link for this? PLease mail me. I need this urgently. Thank you.

                                                                      - Akshata

                                                                        JournalDev
                                                                        DigitalOcean Employee
                                                                        DigitalOcean Employee badge
                                                                        March 31, 2015

                                                                        The good lesson! Please tell me how to run the app on a VPS/VDS?

                                                                        - Vasiliy

                                                                          JournalDev
                                                                          DigitalOcean Employee
                                                                          DigitalOcean Employee badge
                                                                          April 14, 2015

                                                                          Thank you very much… this article gives me correct thinking direction towards web application… Looking for more explosure…

                                                                          - Rahul Pathak

                                                                            JournalDev
                                                                            DigitalOcean Employee
                                                                            DigitalOcean Employee badge
                                                                            May 26, 2015

                                                                            Very nice and helpfull tutorial

                                                                            - Dada

                                                                              JournalDev
                                                                              DigitalOcean Employee
                                                                              DigitalOcean Employee badge
                                                                              May 27, 2015

                                                                              Thank u very much…

                                                                              - glory

                                                                                JournalDev
                                                                                DigitalOcean Employee
                                                                                DigitalOcean Employee badge
                                                                                July 5, 2015

                                                                                Very nice and helpfull tutorial

                                                                                - balwinder singh

                                                                                  JournalDev
                                                                                  DigitalOcean Employee
                                                                                  DigitalOcean Employee badge
                                                                                  July 15, 2015

                                                                                  Is there any tutorial for Jsp Servlets with Gradle in Eclipse IDE

                                                                                  - Arpita

                                                                                  JournalDev
                                                                                  DigitalOcean Employee
                                                                                  DigitalOcean Employee badge
                                                                                  September 3, 2015

                                                                                  Hi Arpita, If you’d like an example of JSP servlets being server with gradle as your build tool, check out https://github.com/jadekler/git-java-websiteskeleton. This is a pretty light skeleton that uses gradle as the build tool serving JSP through Spring’s WebMVC layer.

                                                                                  - Jean de Klerk

                                                                                    JournalDev
                                                                                    DigitalOcean Employee
                                                                                    DigitalOcean Employee badge
                                                                                    July 28, 2015

                                                                                    I real enjoyed it, but i encounter an error “Server Tomcat v7.0 Server at localhost failed to start.” how can i fix it, i tried several solutions from different communities like deleting .snap file and temp0 folder and even deleting the server and reconfiguring it, but still i didnt fix it.

                                                                                    - Imma

                                                                                      JournalDev
                                                                                      DigitalOcean Employee
                                                                                      DigitalOcean Employee badge
                                                                                      September 6, 2015

                                                                                      I am confused between web server and weB container, tom cat is a web container or server ? Please explain

                                                                                      - skini

                                                                                      JournalDev
                                                                                      DigitalOcean Employee
                                                                                      DigitalOcean Employee badge
                                                                                      September 26, 2015

                                                                                      tomcat is a container web server contains the container(tomcat) the web server intercept the http request , the container do his work and reply

                                                                                      - belhassen bouteraa

                                                                                        JournalDev
                                                                                        DigitalOcean Employee
                                                                                        DigitalOcean Employee badge
                                                                                        October 12, 2015

                                                                                        tomcat is a server

                                                                                        - Ash

                                                                                          JournalDev
                                                                                          DigitalOcean Employee
                                                                                          DigitalOcean Employee badge
                                                                                          September 10, 2015

                                                                                          Thank You Dada for your clear and precise tutorial. #Respect and Gratitude from Bangladesh

                                                                                          - Rokon

                                                                                            JournalDev
                                                                                            DigitalOcean Employee
                                                                                            DigitalOcean Employee badge
                                                                                            September 18, 2015

                                                                                            Thanks !

                                                                                            - Nikita

                                                                                              JournalDev
                                                                                              DigitalOcean Employee
                                                                                              DigitalOcean Employee badge
                                                                                              November 11, 2015

                                                                                              Thank you a lot for good explanation how to do WEB project using JSP on Eclipse. Good example how tutorials have to be made. Thank you!!!

                                                                                              - Pavel

                                                                                                JournalDev
                                                                                                DigitalOcean Employee
                                                                                                DigitalOcean Employee badge
                                                                                                January 2, 2016

                                                                                                Very Nice and very useful explanation.

                                                                                                - RAKESH JALCHHATRI

                                                                                                  JournalDev
                                                                                                  DigitalOcean Employee
                                                                                                  DigitalOcean Employee badge
                                                                                                  January 10, 2016

                                                                                                  Very straight forward approach. Clear concise, well done and thanks.

                                                                                                  - bill

                                                                                                    JournalDev
                                                                                                    DigitalOcean Employee
                                                                                                    DigitalOcean Employee badge
                                                                                                    March 2, 2016

                                                                                                    Helpful and clear and precise. Thanks :D

                                                                                                    - Abir

                                                                                                      JournalDev
                                                                                                      DigitalOcean Employee
                                                                                                      DigitalOcean Employee badge
                                                                                                      March 23, 2016

                                                                                                      It is very useful and :) Thanks:)

                                                                                                      - Deepa Mohan

                                                                                                        JournalDev
                                                                                                        DigitalOcean Employee
                                                                                                        DigitalOcean Employee badge
                                                                                                        May 3, 2016

                                                                                                        Thanks,very helpful!

                                                                                                        - Pavel

                                                                                                          JournalDev
                                                                                                          DigitalOcean Employee
                                                                                                          DigitalOcean Employee badge
                                                                                                          May 9, 2016

                                                                                                          Nice tutorial For me that didn’t know about JSP before. Thank you.

                                                                                                          - Khaninkit

                                                                                                            JournalDev
                                                                                                            DigitalOcean Employee
                                                                                                            DigitalOcean Employee badge
                                                                                                            June 14, 2016

                                                                                                            Good Job. Explained in a simple way.

                                                                                                            - Aboobacker Cheethayil

                                                                                                              JournalDev
                                                                                                              DigitalOcean Employee
                                                                                                              DigitalOcean Employee badge
                                                                                                              June 16, 2016

                                                                                                              excellent tutorial! thanks!

                                                                                                              - israel

                                                                                                                JournalDev
                                                                                                                DigitalOcean Employee
                                                                                                                DigitalOcean Employee badge
                                                                                                                June 20, 2016

                                                                                                                thank u for me to undersatnd the topic…

                                                                                                                - snega

                                                                                                                  JournalDev
                                                                                                                  DigitalOcean Employee
                                                                                                                  DigitalOcean Employee badge
                                                                                                                  June 29, 2016

                                                                                                                  Everything is Crystal Clear… Simple, easy a,d understandable. I Completed learning Servlet and JSP, but few topics was still unclear and i was in fix . Now this post clear my all doubts . Thank you very much Mr Pankaj . Good job DUDE .:) Keep writing … Regards Sachindra N. Pandey

                                                                                                                  - Sachindra

                                                                                                                    JournalDev
                                                                                                                    DigitalOcean Employee
                                                                                                                    DigitalOcean Employee badge
                                                                                                                    July 28, 2016

                                                                                                                    This is great Pankaj. I find it very helpful and interesting. Thanks man

                                                                                                                    - FUNSO STEPHEN IYAJU

                                                                                                                      JournalDev
                                                                                                                      DigitalOcean Employee
                                                                                                                      DigitalOcean Employee badge
                                                                                                                      September 14, 2016

                                                                                                                      Can i move a wordpress site https://songlers.com to a java site??? is there any solution which can help me to move or import this site to java web server or to a java cms.

                                                                                                                      - mahendra sharma

                                                                                                                        JournalDev
                                                                                                                        DigitalOcean Employee
                                                                                                                        DigitalOcean Employee badge
                                                                                                                        November 3, 2016

                                                                                                                        thank u very much

                                                                                                                        - sumit

                                                                                                                          JournalDev
                                                                                                                          DigitalOcean Employee
                                                                                                                          DigitalOcean Employee badge
                                                                                                                          November 11, 2016

                                                                                                                          sir Thankyou so much Its very useful to the beginners like me. simple presentation makes it easier to learn

                                                                                                                          - ziara

                                                                                                                            JournalDev
                                                                                                                            DigitalOcean Employee
                                                                                                                            DigitalOcean Employee badge
                                                                                                                            December 3, 2016

                                                                                                                            Hi, This looks like a good tutorial, except for one thing. You are calling it a beginning tutorial but you are leaving out a very important detail that as beginners in dynamic web development, we would have no clue to set up. This is Eclipse and Tomcat. I have no idea how to get this or what to do. I could spend hours or days to figure it out but it seems like this would be a very important and helpful topic to include in this beginners tutorial. I wondered if there was a way to set up something to simulate a client/server system to practice web development. I’m assuming that Tomcat is some kind of server, but where and how do you get it and set it up for the way you are telling us to use it??? Please respond ! Thank you! RRR

                                                                                                                            - RRR

                                                                                                                            JournalDev
                                                                                                                            DigitalOcean Employee
                                                                                                                            DigitalOcean Employee badge
                                                                                                                            December 4, 2016

                                                                                                                            If someone is looking to start with “Java Web Development”, I assume that he should have understanding of java and Eclipse IDE. Just search for “tomcat download” and you will get it within 2 mins.

                                                                                                                            - Pankaj

                                                                                                                              JournalDev
                                                                                                                              DigitalOcean Employee
                                                                                                                              DigitalOcean Employee badge
                                                                                                                              January 5, 2017

                                                                                                                              simple explanation ,I got it easily sir thanks

                                                                                                                              - sandy

                                                                                                                                JournalDev
                                                                                                                                DigitalOcean Employee
                                                                                                                                DigitalOcean Employee badge
                                                                                                                                February 6, 2017

                                                                                                                                Excellent, really very helpful, exactly what I needed.

                                                                                                                                - rusk

                                                                                                                                  JournalDev
                                                                                                                                  DigitalOcean Employee
                                                                                                                                  DigitalOcean Employee badge
                                                                                                                                  February 16, 2017

                                                                                                                                  Hi thanks for this shorthand explanation.But i have a question. Are servlet and jsp relevant? I already learned java SE and i want to learn java EE .please guide me where should i start from?

                                                                                                                                  - hossein

                                                                                                                                    JournalDev
                                                                                                                                    DigitalOcean Employee
                                                                                                                                    DigitalOcean Employee badge
                                                                                                                                    May 11, 2017

                                                                                                                                    I executed the firstServlet program but getting 404 Not found error. Kindly suggest why error is coming.

                                                                                                                                    - priya

                                                                                                                                      JournalDev
                                                                                                                                      DigitalOcean Employee
                                                                                                                                      DigitalOcean Employee badge
                                                                                                                                      June 9, 2017

                                                                                                                                      Very crisp and nice

                                                                                                                                      - Srini

                                                                                                                                        JournalDev
                                                                                                                                        DigitalOcean Employee
                                                                                                                                        DigitalOcean Employee badge
                                                                                                                                        June 12, 2017

                                                                                                                                        Hi Thank you for your awesome post, I do enjoy a lot from it. However I do have a question: When I get that hello world example work, it only shows: Served at: /FirstServletProject in the page after clicking run. Is that the result we are supposed to get? If not, could you please help me of what is wrong with it? Thanks a lot.

                                                                                                                                        - Strong

                                                                                                                                          JournalDev
                                                                                                                                          DigitalOcean Employee
                                                                                                                                          DigitalOcean Employee badge
                                                                                                                                          July 29, 2017

                                                                                                                                          The content is very simple to understand. Thanks a lot for this, it really helpfull.

                                                                                                                                          - Jijo

                                                                                                                                            JournalDev
                                                                                                                                            DigitalOcean Employee
                                                                                                                                            DigitalOcean Employee badge
                                                                                                                                            August 2, 2017

                                                                                                                                            thank you, my Idol. I will still follow you to learn a lot of Java experience. Regards.

                                                                                                                                            - Quang Lai

                                                                                                                                              JournalDev
                                                                                                                                              DigitalOcean Employee
                                                                                                                                              DigitalOcean Employee badge
                                                                                                                                              August 15, 2017

                                                                                                                                              Hi, great blog post. It’s a fantastic tutorial. You really had my head scratching so I’m going to beaver away later and dig right into it. I run a small website that creates AngularJs tutorials and it might compliment what you are doing here. You and your readers may find the tutorials useful. You can find them here: https://tests4geeks.com/angular-2-tutorial/ https://tests4geeks.com/angular-google-maps-tutorial/ https://tests4geeks.com/single-page-application-using-angularjs-tutorial/ Thanks again for the great post. I look forward to reading more of your articles in the future.

                                                                                                                                              - tests4geeks

                                                                                                                                                JournalDev
                                                                                                                                                DigitalOcean Employee
                                                                                                                                                DigitalOcean Employee badge
                                                                                                                                                August 23, 2017

                                                                                                                                                I had so many mistakes in java but nowadays it’s improving.

                                                                                                                                                - Alex

                                                                                                                                                  JournalDev
                                                                                                                                                  DigitalOcean Employee
                                                                                                                                                  DigitalOcean Employee badge
                                                                                                                                                  December 23, 2017

                                                                                                                                                  HTML is the common language between server and client and stands for HyperText Markup Language. typo HTML >> it is http rt?

                                                                                                                                                  - RIYAS K T

                                                                                                                                                    JournalDev
                                                                                                                                                    DigitalOcean Employee
                                                                                                                                                    DigitalOcean Employee badge
                                                                                                                                                    March 1, 2018

                                                                                                                                                    Thank you so much! This is a wonderful start.

                                                                                                                                                    - Kartik Arora

                                                                                                                                                      Try DigitalOcean for free

                                                                                                                                                      Click below to sign up and get $200 of credit to try our products over 60 days!

                                                                                                                                                      Sign up

                                                                                                                                                      Join the Tech Talk
                                                                                                                                                      Success! Thank you! Please check your email for further details.

                                                                                                                                                      Please complete your information!

                                                                                                                                                      Congratulations on unlocking the whale ambience easter egg!

                                                                                                                                                      Click the whale button in the bottom left of your screen to toggle some ambient whale noises while you read.

                                                                                                                                                      Thank you to the Glacier Bay National Park & Preserve and Merrick079 for the sounds behind this easter egg.

                                                                                                                                                      Interested in whales, protecting them, and their connection to helping prevent climate change? We recommend checking out the Whale and Dolphin Conservation.

                                                                                                                                                      Become a contributor for community

                                                                                                                                                      Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

                                                                                                                                                      DigitalOcean Documentation

                                                                                                                                                      Full documentation for every DigitalOcean product.

                                                                                                                                                      Resources for startups and SMBs

                                                                                                                                                      The Wave has everything you need to know about building a business, from raising funding to marketing your product.

                                                                                                                                                      Get our newsletter

                                                                                                                                                      Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

                                                                                                                                                      New accounts only. By submitting your email you agree to our Privacy Policy

                                                                                                                                                      The developer cloud

                                                                                                                                                      Scale up as you grow — whether you're running one virtual machine or ten thousand.

                                                                                                                                                      Get started for free

                                                                                                                                                      Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

                                                                                                                                                      *This promotional offer applies to new accounts only.