0

ZK5 Spring Listener Question

asked 2010-10-12 23:42:18 +0800

Tessla gravatar image Tessla
330 2

updated 2010-10-12 23:43:49 +0800

So I see that you specify in the web.xml file based on documentation:

<listener>
</listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Does the listener have to be web.context.ContextLoaderListener? Are there other listeners that are available for use besides the one shown above? If I created my own listener in my own package test.package.MyCustomListener.java, would I be able to use that?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-10-13 00:07:32 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

Hi Tessla,
Sure you can use your own listener. listener classes are used to listen to web application events. For example in this case spring's ContextLoaderListener is responsible for start up and shut down Spring's root WebApplicationContext. You could have your own listener that implements javax.servlet.ServletContextListener or javax.servlet.http.HttpSessionListener

link publish delete flag offensive edit

answered 2010-10-13 08:28:49 +0800

gpan gravatar image gpan
33 1

First question, is ContextLoaderLister what is specifically used for "Spring Web Flow" and does not need to be used to retrieve Spring Beans?

Second, is the listener able to be used in the web.xml file required to use WebApplicationContext and implements either javax.servlet.ServletContextListener or javax.servlet.http.HttpSessionListener?

Reason why I ask is because if a Spring project was made not using web, or any web flow usage, if it would be possible to use an existing listener that does not implement ServletContextLisener or HttpSessionListener?

link publish delete flag offensive edit

answered 2010-10-13 19:51:06 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

Hi gpan,
>> is ContextLoaderLister what is specifically used for "Spring Web Flow" and does not need to be used to retrieve Spring Beans?
You might need to dig into spring documentation for this.
>>is the listener able to be used in the web.xml file required to use WebApplicationContext and implements either javax.servlet.ServletContextListener or javax.servlet.http.HttpSessionListener?
First of all make sure what is the purposeof your listener. If you implement ServletContextLisener you are listening to servlet loading events and if you are implementing HttpSessionListener you are listening to http session events.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-10-12 23:42:18 +0800

Seen: 349 times

Last updated: Oct 13 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More