servlet-listeners

JSF: How to redirect a user to a another page according to the value of a specific FacesContext session attribute

a 夏天 提交于 2020-01-01 19:28:11
问题 In my JSF application, I need to redirect the user from Page A to page B if a session attribute such as userRole has a value of "contributor", and to a page C, for example, if it is "author". I'm told that I have to implement a page listener, or a session listener perhaps. Although I understand writing a listener class is quite straightforward and standard, I don't know how to set it up on the JSF page itself (to listen to the session). Anybody? 回答1: A session listener (HttpSessionListener)

web.xml order or filter and listener

霸气de小男生 提交于 2020-01-01 10:54:30
问题 For a Java EE web application, I have a listener that implements ServletRequestListener, and a Filter. Is there a way to specify at web.xml that the filter should be called before the listener? I've already tried declaring the filter and its mapping before the listener, but the listener is still executed before. Any idea? <filter> <filter-name>myfilter</filter-name> <filter-class>com.example.MyFilter</filter-class> </filter> <filter-mapping> <filter-name>myfilter</filter-name> <url-pattern>/*

web.xml order or filter and listener

心不动则不痛 提交于 2020-01-01 10:53:05
问题 For a Java EE web application, I have a listener that implements ServletRequestListener, and a Filter. Is there a way to specify at web.xml that the filter should be called before the listener? I've already tried declaring the filter and its mapping before the listener, but the listener is still executed before. Any idea? <filter> <filter-name>myfilter</filter-name> <filter-class>com.example.MyFilter</filter-class> </filter> <filter-mapping> <filter-name>myfilter</filter-name> <url-pattern>/*

ServletContextListener not being invoked

亡梦爱人 提交于 2019-12-30 05:54:46
问题 I creating a Java EE 7 project using Eclipse Maven plugin. My problem is when I run the application the class that implements SerlvetContextListener does not get invoked. What is causing this problem? @WebListener public class ApplicationContextListener implements ServletContextListener{ @Override public void contextInitialized(ServletContextEvent sce) { Request request = new HttpRequest(sce); new Thread (request).start(); HibernateUtil.getSessionFactory(); } @Override public void

How to inject dependencies into HttpSessionListener, using Spring?

只谈情不闲聊 提交于 2019-12-28 02:06:14
问题 How to inject dependencies into HttpSessionListener, using Spring and without calls, like context.getBean("foo-bar") ? 回答1: Since the Servlet 3.0 ServletContext has an "addListener" method, instead of adding your listener in your web.xml file you could add through code like so: @Component public class MyHttpSessionListener implements javax.servlet.http.HttpSessionListener, ApplicationContextAware { @Override public void setApplicationContext(ApplicationContext applicationContext) throws

Severe exception on servlet with java.lang.NoClassDefFoundError

我的梦境 提交于 2019-12-25 09:03:41
问题 I get this exception on my tomcat8 running on this java version OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13) SEVERE [http-nio-80-exec-9] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [restSdkService] in context with path [/RestService] threw exception [java.lang.NoClassDefFoundError: Could not initialize class com.example.bean.SomeBean] with root cause java.lang.NoClassDefFoundError: Could not initialize class com.example

implementing HttpSessionListener

老子叫甜甜 提交于 2019-12-24 03:27:56
问题 I am facing a similar problem and have learnt that my listener class will be instantiated when the web.xml is read. I have few functions in the listener class that are used by the main servlet's doPost(which interacts with the database(mysql) to read/write data regarding the users.)along with the methods of HttpSessionListener. So what prevents the container from loading the listener class. I am getting the 404 error. snippet: public class EntryServlet extends HttpServlet{ public void doPost

I'm getting “org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart”. Some clues?

£可爱£侵袭症+ 提交于 2019-12-24 00:08:02
问题 I'm developing a kind of complex hello world-spring webapp (since it has just the minimum functionality: one controller and one view (made with thymeleaf), simple database connection (oracle) and simple email sending capabilities). Now I'm trying to deploy this webapp into tomcat-7 using my IDE (IntelliJ Idea 12.1.3 Ultimate) with not success at all while I'm obtaining from console: Artifact infoSynth:war exploded: Artifact is being deployed, please wait... org.apache.catalina.core

Adjusting web.xml listeners, filters and servlets

非 Y 不嫁゛ 提交于 2019-12-22 10:55:02
问题 Following is outline of what I have in my web.xml config file. I need help putting this into the correct order. web.xml web-app 1. contextConfigLocation applicationContext.xml 2. defaultHtmlEscape true 3. listeners 4. servlets 5. filters <order sensitive> 6. session-config timeout 120 7. error page 404 500 UPDATE: I'm getting ClassNotFoundException on all my listeners in tomcat's logs/localhost.log There are not problems after the application starts just log entries that indicate that

Injecting dependencies to ServletContextListener with Guice

喜欢而已 提交于 2019-12-22 05:58:52
问题 Since ServletContextListener is created by the server, not by Guice I can't find a way to make it work together. How do I get guice injector at ServletContextListener? Maybe there is better way to shutdown services like logger or persistance then doing it at contextDestroyed method and initialize them at contextInitialized? 回答1: The extension GuiceServlet puts the injector in the servlet context, so you can get it by doing something like this: public class MyServletContextListener implements