Tomat
This page is for Tomcat and Java Development
- Install Tomcat for Development
- Can I use multiple Tomcat in same machine?
- How to debug Tomcat application from Eclipse
- Real application
- Tomcat Error Page
- Tomcat server.xml(Disclose)
Install Tomcat for Development
My Env
- Windows 7 64bit
- Eclipse4.3 KEPLER
- Tomcat7(42)
Steps
- Install Java(JDK) and Eclipse
- Download and Unzip Tomcat
- Install Tomcat plugin in Eclipse
- Setting in Eclipse
- Check
Install for Windows
Windows and Linux, Mac are same steps
I strongly recommended zip or tar.gz version, not use installer version for development.
Certainly, installer version is easy to install and manage, but not flexible for development.
Install Java(JDK) and Eclipse
If you install only JRE, please install JDK instead
Install Java and Eclipse is just straight forward. No explanation.
Set JAVA_HOME env(optional)
This is Java JDK path.
By default, C:\Program Files\Java\jdk1.7.0_40\bin is java home.
Add new environment variable for Windows
Download and Unzip
Download Tomcat and unzip under c: The name is long, I thought. Change “tomcat7”.
Unzip under c:tomcat7
Install Tomcat plugin in Eclipse
Download plugin form Eclipse Totale.
Decompress com.sysdeo.eclipse.tomcat_x.x.x and save it into eclipse\dropins
dropins folder is under eclipse you installed. In my case c:\eclipse\dropins.
That’s all. You restart eclipse, you can see tomcat mark on the top tool bar
Setting
Next is eclipse tomcat setting. To use Tomcat from eclipse, we need setting.
Eclipse “Window”-> “Preferences” -> “Tomcat7”
Please select Tomcat version(in this case Tomcat7) and select tomcat7 directory.
Other is not required to change.
Check
Let’s check tomcat7 works.
Press tomcat button at the top of eclipse(withing red frame)
Tomcat runs and display log on eclipse console
Default application location is C:\tomcat7\webapps\ROOT
Access http://localhost:8080, you can see default application page.
Can I use multiple Tomcat in same machine?
Yes we can. It’s just process
Actually, I use 2 tomcat in same machine and test 2 Web applications which uses different tomcat process and port.
Create Easy Application for Development
Context file
C:\tomcat7\conf\Catalina\localhost\ROOT.xml
This mean TOMCAT_HOME/conf/Catalina/localhost, ROOT.xml is root application, you can access this at the top page
if you want to change path, please use other name, for example application.xml etc…
Name | Description |
---|---|
TOMCAT_HOME | Tomcat install directory |
Catalina | Tomcat Engine name(described in server.xml) |
localhost | Host name(described in server.xml) |
Example(windows)
<?xml version="1.0"?> <Context reloadable="true" workDir="C:\Users\atmarkplant\workspace\TomcatExample\web" docBase="C:\Users\atmarkplant\workspace\TomcatExample" path="TomcatExample"/>
Name | Description |
---|---|
workDir | Working directory tomcat extract compiled jsp or servlet |
docBase | Context root, for development, this is Eclipse project directory |
reloadable | Whether reload setting, if you change sources automatically |
path | Application URL path |
Real application
Basically, we prepared .war file for application
In application, we run application as root, so ROOT.xml as context file(TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml).
And, ROOT.xml is
<Context path="" docBase="c:\war.app.war"/>
Set full path of war file as docBase
Very efficiently written article. It will be beneficial to everyone who employess it, including yours truly :). Keep doing what you are doing – can’r wait to read more posts.