The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: annotations in JSP 2.1 specification

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 1 - Last Post: Nov 30, 2005 11:08 AM by: jluehe
toshe

Posts: 7
annotations in JSP 2.1 specification
Posted: Nov 22, 2005 2:17 AM
  Click to reply to this thread Reply

Hi experts,

I have read the JSP 2.1, Servlet 2.5 and JavaEE 5 specifications. However nothing is explicitely specified about annotations in JSP and tag files. The only assumption which can be made is that as JSP files extend javax.servlet.Servlet so they could be annotated. Looking at table J2EE.5-1 “Components classes supporting injection” only tag handlers and tag library event listeners are specified. As event listeners are both mentioned in JSP and Servlet rows of the table, why JSP pages are not specified in the JSP row? Should it be able to annotate JSP page?

The other relevant question is if the event listeners described in the web.xml support all 7 annotations described in Servlet 2.5 specification why the other event listeners described in TLD should support only @Resource, @EJB, @WebServicesRef?

And finally why JSP 2.1 specification limits usage of @InjectionComplete annotation? Why tags, event listeners (and JSP pages) cannot define a method and annotate it with @InjectionComplete?

Thanks,
Todor

jluehe

Posts: 281
Re: annotations in JSP 2.1 specification
Posted: Nov 30, 2005 11:08 AM   in response to: toshe
  Click to reply to this thread Reply

Hi Todor,

the reason that annotations are not supported on JSP pages or tag files is because all the information represented by annotations needs to be known at deployment time. If an annotation is included in a JSP page, it won't be seen at deployment time (unless the JSP was being precompiled during deployment).

TLD listeners support the exact same annotations as Servlet event listeners. JSP.7.1.11 is going to reflect this and is going to list the following supported annotations:

@Resource + @Resources
@EJB + @EJBs
@WebServiceRef
@PostConstruct
@PreDestroy
@PersistenceContext + @PersistenceContexts
@PersistenceUnit + @PersistenceUnits

Notice that @InjectionComplete has been replaced by @PostConstruct and @PreDestroy listed above.

Let me know if you have any further questions.


Jan




 XML java.net RSS