In this tutorial I will teach you how to add tomcat server in eclipse IDE and other functionality that you would require to develop a web application. It is assumed that you have preliminary knowledge of using eclipse, If not please visit this link.
Now you have installed the Eclipse so next thing would be to start using Tomcat from inside eclipse.
- What is Tomcat
- Download Tomcat
- Add Tomcat in eclipse
- Add project in tomcat
- Run web application in tomcat from eclipse
What is Tomcat
Apache Tomcat (Commonly known as Tomcat) is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle Corporation (Previously known as Sun Microsystems).
To download the current version (7.0.34) of Tomcat please visit here. There are different download links available on this page(32bit/64bit/zip format/tar format..). Select one which is most suitable to you. If you don’t want to go in details download the tomcat from first download link in ZIP format. Once download extract the folder in local file system (Assuming extracted file location is “d:/tomcat“). After extraction, file structure would look like below.
Add Tomcat to Eclipse
It’s time to open Eclipse. Once opened open server view (To know more about views click here)
Currently there is no server available. You need to add a new one. Click the link “New Server Wizard“. It will show the popup window. Select the proper tomcat version. In current situation select “Tomcat v7.0 Server” and click “Next“.
Now click Next. If you have any web project which you want to add to tomcat server you can do that here in next screen. If there is any web application in given workspace then it will get displayed on left side as below. If you want to add web application in tomcat select the application and click Add button. It will be added to given tomcat instance. Once done with it click Finish
If everything is fine server view will now have a instance of Tomcat server with JBT application added in it.
What if you have already create instance of the tomcat in Eclipse and now you want to add newly create web application in existing tomcat server. To add newly created web application select the tomcat instance in which you want to add web application, right click and clcik “Add and Remove..” menu.
It will open Add and Remove window. Select the web application which you want to deploy and click Add>.
After adding application click Finish. Now server will have two web application in it which can be configured in server view.
Run & Debug web application in tomcat from Eclipse
Now we are done with adding web application in server it’s time to run the application. To run tomcat select tomcat right click and then select “Start” (To start server in run mode) or “Debug” (To start server in run mode) menu. It will start the server in given mode and you can check the output in console view.