简体   繁体   中英

@WebServlet annotation support in java 1.6.013

I'm stepping into the world of Servlets and 3.0 in particular and I saw certain methods and annotations used in examples and tutorials which talked about this being available when JAVA 6.0 is released (which it has) and now when I try to use the above annotation for example in Eclipse it does not recognize it although I have java 1.6.013 installed and in Eclipse it says I'm using jre6. When I tried googling it a bit I stumbled on this page regarding WebServlet Annotation where it states on the top right side: DRAFT. what does that mean? Is @WebServlet supported in 1.6.013 or not? is the problem with my Eclipse?

Thanks a lot for anyone who can lend me a helping hand

EDIT: I now understand I've made a bit of a mess but there is a Jar I've downloaded of the Servlets 3.0 API which at least for the @WebServlet annotation works but gives me hell.

Servlets are defined by a JSR - the Servlet Specification in JSR-154 . Annotations for servlets were introduced in version 2.5 of the servlet specification . All containers that implement the 2.5 version of the specification will support annotations; your problem might lie with the container not implementing it. You can refer section SRV.14.5. Annotations and Resource Injection of the servlet spec where it is defined in black and white.

By the way, you are looking at the javadocs of Java EE 6 (which is in draft at the moment). Servlet Spec 2.5 is part of Java EE 5.

PS: The @WebServlet annotation that you are referring to, makes its appearance in Servlet Spec 3.0 , which is in draft, and is a part of Java EE 6. At the time of writing this, no container is available for download that supports Servlet Spec 3.0; not even a RI (reference implementation) is available. You will find experimental builds though, but be forewarned, the spec itself is not final, so experimental builds are bound to interpet and implement the spec differently.

PPS: Glassfish v3 Preclude Preview seems to have support for most of the Java EE 6 standards. A comparison sheet provides info on what is available in Glassfish v2, v3 Preclude and v3 Preview.

目前, GlassFish v3提供了EJB 3.1和Servlet 3.0以及其他Java EE 6规范的最完整实现。

简而言之,紧随Vineet之后,目前尚未使用3.0,因此您应该关注Java EE 5和2.5。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM