In this article, we will find out about how to create dynamic web project with servlet, jsp in eclipse, how to add external jar files, add new server into our project.


Table of contents


Create dynamic web project Java

  • Select File -> New -> Project.

    Select Project option

  • Go to the New Project dialog.

    New Project dialog

    Select Web folder –> Dynamic Web Project.

  • Click Next button.

    New Dynamic Web Project dialog

    Type our project name, and select Dynamic web module version.

  • Click Next button.

    New Dynamic Web Project dialog

  • Click Next button.

    New Dynamic Web Project dialog

    We should select checkbox Generate web.xml deployment description.

    And finally, click Finish button.


Add new server into our project

In order to run our project, first of all, we need to add new server such as Resin, Tomcat, Glassfish.

  • Right click on our project in Project Explorer. Select New item, then, choose Other item.

    Open menu for New server

  • Go to the New dialog. Select Server folder, choose Server. Click Next button.

    Select Server option

  • Go to the New Server dialog. Choose Resin and Resin 4.0.

    Select Server option

  • Click Next button.

    Configure for server

    In this dialog, we can repair some information about server such as Port, username, password, …

  • Click Next button.

    Add project under Server

  • Click Finish button.


Add external libraries

  • Right click on our project in Project Explorer.

    Select option in File tab

    Select Build Path –> Configure Build Path ....

  • Go to the Properties for ... dialog.

    Properties for ... dialog

    Click Add External JARs... button.

  • Go to the JAR selection dialog.

    JAR selection dialog

    At this dialog, we will choose some jar file that we need in our project.

  • After finished to choose some jar files, we have:

    Properties for ...  dialog

    Click Apply button –> OK button.


Refer:

https://www.javahelps.com/2015/04/java-web-application-hello-world.html

https://www.studytonight.com/servlet/creating-servlet-in-eclipse.php

https://stackoverflow.com/questions/2349633/doget-and-dopost-in-servlets

https://stackoverflow.com/questions/11731377/servlet-returns-http-status-404-the-requested-resource-servlet-is-not-availa