How to run a background task in a servlet based web application?

Your problem is that you misunderstand the purpose of the servlet. It’s intented to act on HTTP requests, nothing more. You want just a background task which runs once on daily basis. EJB available? Use @Schedule If your environment happen to support EJB (i.e. a real Java EE server such as WildFly, JBoss, TomEE, Payara, … Read more

Get JSF managed bean by name in any Servlet related class

In a servlet based artifact, such as @WebServlet, @WebFilter and @WebListener, you can grab a “plain vanilla” JSF @ManagedBean @RequestScoped by: Bean bean = (Bean) request.getAttribute(“beanName”); and @ManagedBean @SessionScoped by: Bean bean = (Bean) request.getSession().getAttribute(“beanName”); and @ManagedBean @ApplicationScoped by: Bean bean = (Bean) getServletContext().getAttribute(“beanName”); Note that this prerequires that the bean is already autocreated by … Read more

JPA map collection of Enums

using Hibernate you can do @ElementCollection(targetElement = InterestsEnum.class) @JoinTable(name = “tblInterests”, joinColumns = @JoinColumn(name = “personID”)) @Column(name = “interest”, nullable = false) @Enumerated(EnumType.STRING) Collection<InterestsEnum> interests;

Difference between web server, web container and application server

Your question is similar to below: What is the difference between application server and web server? In Java: Web Container or Servlet Container or Servlet Engine : is used to manage the components like Servlets, JSP. It is a part of the web server. Web Server or HTTP Server: A server which is capable of … Read more

Java EE 6 @javax.annotation.ManagedBean vs. @javax.inject.Named vs. @javax.faces.ManagedBean

First of all let me do some clarifications: Managed bean definition : generally a managed bean is an object that its life cycle (construction, destruction, etc) is managed by a container. In Java ee we have many containers that manage life cycle of their objects, like JSF container, EJB container, CDI container, Servlet container, etc. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)