开发者

Is there a generic version of servlet-api?

I know that each servlet container (e.g. Tomcat, Glassfish, etc.) comes with an implementation of servlet-api.

What I am looking for is a generic (container agnostic) version of servlet-api to com开发者_Go百科pile my application code against.

I would also like source code or Javadoc to use in my IDE during development.

Does such a version of servlet-api.jar exist?


For pure compilation, it doesn't matter which one you picks. You could extract it from Tomcat's /lib directory or grab it from some Maven repo. Please pay attention that you pick the correct version, 2.3, 2.4, 2.5 or 3.0 which is the same as the target runtime and that you never include it in webapp's /WEB-INF/lib.

Since you're using an IDE (based on your question history, I'll bet Eclipse), you could also just associate the dynamic web project with a target runtime. This way Eclipse will automagically include the necessary libs for compiletime.

See also:

  • How do I import the javax.servlet API in my Eclipse project?


What is important is that you import and compile against the javax.servlet versions of these classes, rather than the vendor specific implementations of these interfaces.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜