开发者

How do I replace ServletException after Tomcat 6.0?

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 f开发者_Go百科ile 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!


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜