Fog Creek Software
Discussion Board




Servlets in Eclipse


How do i compile servlets in eclipse?

Medha
Monday, May 24, 2004

Compile them just like any other piece of java code.  Compilers know nothing of servlets.  Now, launching a servlet container for your compiled code....that's another discussion.

Steve
Monday, May 24, 2004

yes...so how do i do it? it cannot resolve javax.servlet when i compile.

Medha
Monday, May 24, 2004

You need to add the jar containing HttpServlet, etc. to your classpath.  Usually, people compile against the HttpServlet class in a jar provided by the maker of their servlet container.  For example, my Eclipse workspace contains a reference to weblogic.jar because I deploy to Weblogic.  If you are using something else (say, Tomcat), you'll have to figure out what the appropriate jar from their distribution is.  Sun might provide a generic implmentation of the servlet base classes for compilation purposes, but I don't know much about that.

Steve
Monday, May 24, 2004

If you have the Sun J2EE SDK installed, there should be a library called "servlet.jar" which is included with that.  That should contain all of the javax.servlet packages.  Add that to your classpath and you should be in good shape.

Ryan
Monday, May 24, 2004

It's not required, but I've been happy with MyEclipse:

http://www.myeclipseide.com

which is a nice (and inexpensive) J2EE plugin for Tomcat.  It makes debugging webapps pretty easy.

Will
Tuesday, May 25, 2004

*  Recent Topics

*  Fog Creek Home