How to Create a New Project and Hello World Program in Advance Java (J2EE)

In this tutorial how to create a new project, how to create Hello World Program and how to execute the project in Advance Java (J2EE) is shown.

To Create a new J2EE Project in Netbeans IDE, follow the below mentioned steps:

  1. Go to File Menu
  2. Select New Project
  3. A new Dialog Box will appear
  4. In the Categories Select “Java Web” and in Projects Select “Web Application”
  5. Then click on Next Button
  6. Write the Project Name
  7. Set the path of the project if required
  8. Then click on Next Button
  9. Now select a Server
  10. And click on Finish Button

To create a new Servlet

  1. Right Click on “Web Pages” Folder
  2. In New, select Servlet
  3. A new Dialog Box will appear
  4. Enter the Class name, it should be same as the action attribute in <form> tag
  5. Then click on Next Button
  6. Now Select the checkbox for Add information to deployment descriptor (web.xml)
  7. Click on Finish Button



<title>My first hello world program</title>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<form action=”HelloWorld” method=”POST”>
<input type=”submit” value=”Click Here”>

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloWorld extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println(“<!DOCTYPE html>”);
out.println(“<title>Servlet HelloWorld</title>”);
out.println(“<h1>” + “Hello World” + “</h1>”);



<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app version=”3.1″ xmlns=”” xmlns:xsi=”” xsi:schemaLocation=””>

Add a Comment

Your email address will not be published. Required fields are marked *