Today is Saturday, 15th May 2021

Archive for the ‘Java’ Category

Deploying To Tomcat using WAR files

When you deploy your Java web apps, you can make use of a Web Application Archive (WAR) file.

The Web Application Archive (WAR) file is a compressed version of your web application. It uses the zip file format but the file has the .war extension.

The best way to visualize it is think of your “webapp” directory being compressed as a zip file with the .war extension.

This includes all of your web pages, images, css etc. It also includes the WEB-INF directory which includes your classes in WEB-INF/classes and supporting JAR files in WEB-INF/lib.

The WAR file format is part of the Java EE / Servlet specification. As a result, all Java EE servers support this format (ie jboss, weblogic, websphere, glassfish and tomcat).

Below, I provide the steps on how to create a WAR file using Maven. I also show how to deploy the WAR file on Tomcat.

1. In your IDE, stop Tomcat

2. Run Maven: $ mvn clean package

3. This generates a file in sub-directory: target/YOURAPP.war

4. Outside of IDE, start Tomcat
– If you are using MS Windows, then you should find it on the Start menu

5. Make sure Tomcat is up and running by visiting: http://localhost:8080

6. Deploy your new WAR file by copying it to <tomcat-install-directory>\webapps

Give it about 10-15 seconds to make the deployment. You’ll know the deployment is over because you’ll see a new folder created in webapps … with your WAR file name.

7. Visit your new app. If your war file was: mycoolapp.war then you can access it with:  http://localhost:8080/mycoolapp/

Advanced Servlets: Servlet Filters Tutorial

As a Java web developer, I recommend that you take advantage of an advanced servlet component: the Servlet Filter.
A Servlet filter is an object that can intercept HTTP requests targeted at your web application.
This article from does a good job of walking you through the development process. Enjoy!
Java Servlet Filters Tutorial

MongoDB Java Tutorials

MongoDB … NoSQL … buzzwords buzzwords buzzwords!
Well, it seems that MongoDB is all the rage. I personally still like MySQL but more and more, I’ve been getting requests to use MongoDB on my client Java projects.
Here are some useful resources that I used to spin up on MongoDB. Now, I can’t promise to make you a MongoDB expert … but you’ll have enough information to be dangerous LOL 🙂