How many instances of RequestDispatcher will be there in JVM . Is it that for every RequestDispatcher which is got from Request will create different instance. supposedly same behaviour is true with RequestDispatcher got from Servlet Request.
Second question is can there exist More the one Instance of HttpSessionActivationListener , HttpSessionAttributeListener , HttpSessionListener or they are Singletons.
third question is :Can there be instances of two different class but both of type lets say HttpSessionListner in one single JVM example MyHttpSessionListner is of type HttpSessionListener and NewHttpSessionListener which is also of type HttpSessionListener. so can both of them deployed at same time and both can have one instance in single JVM or container. If yes whose methods will be called first.
posted 14 years ago
I meant "supposedly same behaviour is true with RequestDispatcher got from ServletContext" .
Was this a wrong question as there is no reply to this.
Wondering ... Huuuu. May be I have some idea about the answer.
each time getRequestDispatcher is called a new instance is created. but most of the Listener classes are singleton . there cannot be two class which implement lets say HttpSessionListener.Thus only one instance of that listener type.
I don't think so regarding only one instance of each listener type if by that you mean only ever one HttpSessionListener etc. From what I've read (and I'm by no means any expert ) you can define multiple listeners in the DD
now both MyListener1 and MyListener2 can implement the same interface (say HttpSessionListener), hence you can have multiple ones. There are rules regarding the notification order as well, I think they are informed in the order they are specified in.
That's for listeners declared in the DD.
but there are other types of listeners that just get informed if they are "alive" at the time (Hint: attribute....)
SCJP 1.4, SCJD, SCWCD 1.4
posted 14 years ago
Thanks Steve for the reply.
I agree with you that we can configure Different Class implementing same Listener type. but how is the event lets say contextInitialized() on ServletContextListner will be treated. Will it call both the ListenerType one after other.
I deployed two Listener of ServletContextListener type and tomcat did not throw any deployment error.