How to create Dynamic Web Project using Maven in Eclipse - Step By Step Guide

In this Post we will discuss step by step to create a new Dynamic Web Project using Maven in Eclipse.

Maven is a very powerful development tool for Java, apart from resolving library dependency, it's easy to builds the project with Maven.

Maven installed on your system
Maven plugin in eclipse

Creating Maven Web Project in eclipse is explained in below steps:

  1. Select new project and then search for Maven and select Maven project as below:

  2. Now Select
  3. Now enter Group Id as package and Artifact Id as Project Name as in below screenshot
  4. Now there might be a JSP error as in below screenshot for "The superclass 'javax.servlet.http.HttpServlet' was not found on the Java Build Path", to resolve this edit POM.xml and add below dependency

  5. Your final project structure will look like as below.

Hope this helps.

Different ways to print an Array in Java

Many times you need to print elements of Array in java language, it can be done in many ways and we will discuss many of those.

We will also try to find out which one is simplest and easiest.

Print Array using default toString method:

As we know all classes have toString method, let's try using that.

Output is not very useful as it prints some random string as below:

Print array using our own Implementation

Now let us iterate over each element and print it as below:

Output is:

Using Arrays.toString()

Since JDK5, java has Arrays class which has many utility methods for Array, like Arrays.toString() method to print elements of Array:

This is the simplest and easiest way to print array in java, for this you need to import java.util.Arrays class.

Output is:

Arrays.toString is not much usefull when array is multidimensional i.e 2-Dimension or 3-Dimension, in such scenario output is as below

Out is as below:

to print multidimensional array use java.util.Arrays.deepToString() method as below:

Output will be as below: