Creating a new project in Eclipse
1. Run eclipse.exe from the installation folder.
2. Select a workspace. (if this is the first time running eclipse, just choose the default workspace which will create a folder called ‘workspace’ inside the user folder within windows.)
3. Close the ‘Welcome’ page.
(You can get this page back again by selecting help-> welcome)
3. Go to file -> new -> project
4. Select Web -> Dynamic Web Project.
5. Enter a project title. For my project, I’ve named it webTest01. Click next.
8. You should now see your newly created java project as webtest01 in the project explorer to the left of the screen.
Now that we have created a new project, lets create our first JSP page.(see below)
Adding a new JSP file to an existing project
1. Go to file -> new -> other. Then select web -> JSP file
2. Once you have created your JSP file, add the text ‘Hello World’ into your project with h1 tags.
3. You have now created your first JSP file. To test this, we now need to install a server and run the project. (see below)
Adding a server and running your project
Setting up a server. Before being able to run your application and access it via a browser, you will first need to install a java web server. You will be prompted to do this the first time you try and run your project, so do this now.
1. Run -> Run.
As we have created a web project, but don’t currently have a web server set up, the above screen should appear.
2. Choose Tomcat v7.0 Server from within the Apache folder. (you won’t be able to choose the others as they do not support the latest version of Java JDK that you have installed. To use older/other servers, you will need to download and compile your project with an older version of the JDK.) Click next.
3. Installing Tomcat.
4. As we don’t have Apache Tomcat installed, click on the download and install… button and have eclipse do this automatically for you.
5. Once complete, you should see your selected install location (in my case c:\tomcat\ in the Tomcat installation directory. Once tomcat is installed, click on the next button.
7. Once your screen looks similar to above, click on the finish button. You will see a some red text appear as the server starts up. This is all good and is just INFO output on tomcat starting and is not typically errors.
8. Once the server has started, you can open a browser and navigate to your now running application.
Your application will always run on localhost (the keyword for your local machine) and underneath the folder of your project name. The default port your application should run on is 8080.
If your server doesn’t start or has errors:
– Investigate if something else is currently using port 8080. In my case, I had another application using the port, which I configured to use a different port and restarted. After this my server worked correctly.
If you receive 404 page not found errors:
– Java is case sensitive. Make sure /webTest01/ is typed in case sensitive as any variance of the case will cause the page to not load.
– If you didn’t use index.jsp, you will need to type the full path to your jsp file.