views:

28

answers:

1

Hey, guys. Newbie to tomcat/apache, java returner here.

I'm trying to run th step-by-step example here (http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html).

Unfortunately, I keep getting an error that says "The project was not built since its build path is incomplete. Cannot find the class file for javax.servlet.http.HttpServletResponse. Fix the build path then try building the project." I looked into it and found out that javax.servlet is commented out by default in a conf/web.xml file for tomcat and that this was because people should now shun the use of servlets or something.

My questions, then, are:

  1. How do I rewrite this so that it's compliant with the principles that caused it?
  2. (Bonus Question) Once I make changes in that tomcat file, conf/web.xml, how do I make it so that those changes follow through into my editor (in this case, Eclipse)?

Thanks!

+1  A: 

Cannot find the class file for javax.servlet.http.HttpServletResponse. Fix the build path then try building the project."

This compilation error means that the JAR file containing the Servlet API is missing in the compile time classpath (the build path). You need to include Tomcat's servlet-api.jar in the build path as per the comments in the build.xml file.

I looked into it and found out that javax.servlet is commented out by default in a conf/web.xml file for tomcat and that this was because people should now shun the use of servlets or something.

I am not sure what you're talking about, but you should in fact not touch the conf/web.xml when still starting with JSP/Servlet development. The default one should be fine. The Servlet API is certainly not discouraged/deprecated or so. It is still the most important core building stone of a Java based webapplication.

That said, it's unclear to me as well what you meant with "How to replace ServletException after Tomcat 6.0" in your question title. Can you elaborate on this in your question as well?

BalusC
Sorry that I could not link the site that made me think I needed to replace it; I require 10 rep before posting more than 1 link in a question.I had found this link, http://faq.javaranch.com/view?InvokerServlet, while trying to find out how to resolve this issue. The part under "Cutting to the Chase" made me think that this was now a bad practice, but now I'm guessing -- because of your insight -- that Invoker Servlets are a particular type that do not condemn the rest.The explicit inclusion of the servlet-api.jar solved the build issue. Thanks!
Danny
The `InvokerServlet` is completely unrelated to this. It's a Tomcat-specific special servlet class which enables you to invoke servlets directly by its package/classname in the URL without the need to have them mapped on a specific `url-pattern` in webapp's `web.xml`. This was later considered a huge security hole, so it was disabled by default since Tomcat 5.0 (oct 2002) and is removed in Tomcat 7.0 (jun 2010). By the way, I still don't understand how your question title is related to this all.
BalusC