CIT 597 Compiling and Running Servlets
Fall 2008, David Matuszek

A lot of people are having much more trouble than I expected, compiling and running servlets. This page is about how I do it.

The "Eclipse IDE for Java EE Developers" is a new version of Eclipse that I have never used. I suspect that it actually works pretty well, if you know how to use it. From what I've seen, though, it isn't obvious how to use it. For example, I didn't see any New --> Servlet menu item.

I use Eclipse to create and compile servlets. That involves getting the servlet and JSP jars, and putting them in Eclipse's build path (the same way you used to add the JUnit jar, though they've automated that now). With those jars installed, I edit until all the syntax errors go away. I use Eclipse "Classic," but I've looked at doing this in EasyEclipse, and I don't see any reason it would be any different.

Once the servlets and JSP are compiled, I copy the .class files into the appropriate locations in the Tomcat directory structure. Then I start the Tomcat server, open a browser, and test what I've done. When it doesn't work, I debug, compile, copy over, and try again.

Note: If the Tomcat server is configured properly, you don't have to stop and restart it each time. If it isn't configured properly, and you don't stop and restart it, it keeps using the old version of the servlet.

I would expect the EE version of Eclipse to already have the necessary jar files, and to put them in the correct Tomcat directory right from the start. That should be easy for Eclipse, and would almost certainly be easy for you, if you knew what to do. Maybe Eclipse EE will even start and stop the server for you. But--and this is a big "but"--it certainly doesn't appear to be obvious.

There's probably a simple tutorial somewhere on the web for using Eclipse EE for servlets. I am too exhausted at the moment to look for one and, more importantly, try it and make sure it works.