Tech Junkie Blog - Real World Tutorials, Happy Coding!: JavaEE: Create Dynamic Web Project With Tomcat And Eclipse

Tuesday, September 14, 2021

JavaEE: Create Dynamic Web Project With Tomcat And Eclipse

In order to host websites in Tomcat we need to create a project to host servlets.  In this post we are going to create Dynamic Web project in Eclipse.

Here are the steps to create a web project in Eclipse:

1. Right-click on "Servers" → "New" → "Other"

2. Expand the "Web" node then select "Dynamic Web Project", then click "Next"→





























3.  Give the project a name then click "Next", then "Next" again



4. When you get to the "Web Module" screen, check the "Generate web.xml deployment descriptor" checkbox.

  5. A Web application call StockTickers has been created

  6. Now let's create a servlet to test out our web application, to create a servlet Right-click on the "StockTickers" project then click "New"→"Servlet".  Change the superclass to javax.servlet.GenericServlet then click "Finish"







A new servlet file will be created, in the StockTickers project

7.  In the service method type in the following code just to test out our application


 public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
  
  PrintWriter out = response.getWriter();
  out.println("Hello stocks");
 }


8. Click on the "Run" menu then click on "Run" again

9.  When you see "Run On Server" screen accept the default and check "Always use this server running this project"



You will see that we've just created a web application on Tomcat call StockTickers on port 8080











7 comments:

  1. Do you know that there are Gaming Laptop Under 2000 throughout the internet? Of course, you can get a chromebook under the price of 300 dollars.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Pretty good post. I just stumbled upon your blog and wanted to say that i have really enjoyed reading your blog posts. Largest Samsung Tablet

    ReplyDelete
  4. I was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
    I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
    Freelance Marketplace WordPress Theme

    ReplyDelete
  5. I was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
    I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
    WordPress Chat Plugin

    ReplyDelete
  6. Migration policy aims to create a framework for legal migration, taking full account of the importance of integration into host societies. EU measures to support legal immigration cover the conditions of entry and residence for certain categories of immigrants, such as highly skilled workers covered by the EU Blue Card Directive, as well as students and researchers. Family reunification and additional rights for permanent residents are also ensured. https://www.immigration-residency.eu/residence-permit-latvia/immigration-law/

    ReplyDelete
  7. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Web Design Melbourne

    ReplyDelete

Search This Blog