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











11 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. I was more than happy to uncover this great site. I need to 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.
    BEST IT COMPANY IN LAHORE PAKISTAN

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

    ReplyDelete
  4. 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
  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.
    Freelance Marketplace WordPress Theme

    ReplyDelete
  6. 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
  7. 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.
    classified WordPress theme

    ReplyDelete
  8. 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
  9. 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
  10. 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

Search This Blog