Servlets and JSP tutorial - Installing apache and glassfish server on netbeans

by - 3:43 AM

To use servlets and JSP, we either need eclipse or netbeans. I prefer netbeans and in this tutorial we'll see how to set up servlets and jsp in netbeans from start to end.

Step 1. Download the Netbeans IDE that includes Java EE
Since servlets or JSP are a part of the java enterprise edition, in order to use it on netbeans first go to https://netbeans.org/downloads/ and download the Java EE netbeans as described in the image below because it includes the servers and html5 platforms that we need. 
You can download the one on the right end if you have a good internet connection since it includes all required platforms.
Step 2. Install and open the netbeans IDE you just downloaded.(make sure the version is 8.2 and later) 

Step 3. Once you open the IDE, open a new project and choose Java Web and Web applications under Java web and complete the procedure as follows and give your project a name for example we're using myProject (just for practice) and click finish.



Once you assign your project name, click next and finish without changing the glassfish server settings.


Step 4.Run your new project
Once you create your new project, do not make any changes to the existing code. Just run it to see weather it works properly or not. When you run your code, it should open one of the browsers on your PC and display something like TODO write content.

Step 5. Servlet code
Your servlet code is a java class, therefore all you to do is just right click on your project and create a java class as follows, it should be in source packages. 
A servlet consists of an xml document, so you can create your new xml and save.
Step 5. JSP 
To create your justp you just need to choose JSP above the XML document, the way you just created it.

Hope this works well for you.
If you encounter any problems, errors or have any questions, drop your comments below.

You May Also Like

0 comments