Page 1 of 1

About Question enthuware.jwpv6.2.582 :

Posted: Sun May 22, 2016 5:02 pm
by himaiMinh
Let me add one more listener:
Any class annotated with WebListener must implement one or more of the ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, HttpSessionListener or HttpSessionAttributeListener interface.
Let me add "as well as AsyncListener."

Re: About Question enthuware.jwpv6.2.582 :

Posted: Sun May 22, 2016 10:59 pm
by admin
JavaDoc description of this annotation doesn't mention AsyncListener: https://docs.oracle.com/javaee/6/api/ja ... tener.html

Re: About Question enthuware.jwpv6.2.582 :

Posted: Tue Aug 16, 2016 12:45 pm
by johnlong
Any class annotated with WebListener must implement one or more of the ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, HttpSessionListener or HttpSessionAttributeListener interface.

Where did you get this requirement? Could you please indicate source?

Re: About Question enthuware.jwpv6.2.582 :

Posted: Tue Aug 16, 2016 9:09 pm
by admin
johnlong wrote:Any class annotated with WebListener must implement one or more of the ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, HttpSessionListener or HttpSessionAttributeListener interface.

Where did you get this requirement? Could you please indicate source?
Section 8.1.4, Servlet 3.0 specification.

HTH
Paul.

Re: About Question enthuware.jwpv6.2.582 :

Posted: Wed Aug 17, 2016 1:42 pm
by johnlong
Thanks.

1. I have annotated my class @WebListener and my class implements AsyncListener and works fine.
2. Also I am able to annotate my class @WebListener not implementing any Listener interfaces at all.

Re: About Question enthuware.jwpv6.2.582 :

Posted: Wed Aug 17, 2016 8:44 pm
by admin
Some times servlet containers fail to adhere to the specification 100%. The reason could be a mistake or something that only they can tell.

Re: About Question enthuware.jwpv6.2.582 :

Posted: Thu Aug 18, 2016 12:23 am
by johnlong
Ok, but then according to specification we cannot annotate AsyncListener as @WebListener?

Re: About Question enthuware.jwpv6.2.582 :

Posted: Thu Aug 18, 2016 8:57 am
by admin
You can annotate any class with @WebListener if the class implements one of the valid interfaces for being a web listeners i.e. HttpServletListener, ContextListener etc.

Re: About Question enthuware.jwpv6.2.582 :

Posted: Thu Aug 18, 2016 4:35 pm
by johnlong
I am very sorry, I did not get your last explanation.