Back to: Java Servlets Tutorials
Creating Servlet using NetBeans IDE
In this article, I am going to discuss how to use Create Java Servlet Application using NetBeans IDE. Please read our previous article where we discussed how to use Create Servlet Application using MyEclipse IDE.
how to use Create Servlet Application using NetBeans IDE?
Download NetBeans IDE from https://netbeans.org/downloads/6.1/index.html
Once you download and install NetBeans IDE, then open it and it will show the following window.
In order to create a Project using NetBeans, click on File -> New Project option from the context menu as shown in the below image.
It will open the following “New Project” window. Here, you need to select “WebApplication” Project templates and then click on the “Next” button as shown in the below image.
Once you click on the Next button, it will open the following Name and Location window where you need to give the name and location of your project. Here, I provided the project Name as “WebApplication1” and then click on the “Next” button as shown in the below image.
Once you click on the Next button, it will open the Server and Settings window. Here, you need to select the server, Java EE Version and Context path as shown in the below image and click on the Next button.
Next, select the Frameworks (if any) and click on the “Finish” button. Here we are not selecting any Framework.
Once you click on the Finish button, it will create the project for us.
Creating a Servlet using NetBeans:
In order to create a Servlet, right click on your project and then select New -> Servlet option as shown in the below image.
It will open the following New Servlet window. Give the Servlet name as “DemoServlet” and click on the “Next” button as shown in the below image.
From the next window, configure the servlet deployment and click on the “Finish” button as shown in the below image.
Now open the DemoServlet and write down the Servlet Code here.
Creating HTML Page:
Now, create a HTML Page. Right click on the project, New -> HTML
Write the HTML code here.
Now change the welcome file as index.html.
Now start the server and deploy your project. Click on run -> Run Project (WebAplication1)
You can see that default page of your project is open, write your name -> login.
Final Output
In the next article, I am going to discuss Servlet Communication. Here, in this article, I try to explain how to use Create Servlet Application using NetBeans IDE. I hope you enjoy this Create Servlet Application using NetBeans IDE article.