Although I crawled through these four SO questions, I still only get a blank page when the first JSF page I created within my servlet is called. It is deployed via IntelliJ IDEA on a Tomcat 7 server. On Error Log level "all", I don't get any error messages. The source code in the browser stays completely empty. It seems like FacesServlet isn't invoked, but IMO it can't be due to the url-mapping, it seems OK to me!?? Is there any other possibility, also as for looking into an error log?
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>incomingURLs</param-name>
<param-value>http://localhost:8080,http://localhost:63342,https://localhost:63342</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Diagapp</servlet-name>
<servlet-class>com.brainsee.diagapp.DispatcherServlet</servlet-class>
<multipart-config>
<location>/tmp</location>
<max-file-size>20848820</max-file-size>
<max-request-size>418018841</max-request-size>
<file-size-threshold>1048576</file-size-threshold>
</multipart-config>
</servlet>
<servlet-mapping>
<servlet-name>Diagapp</servlet-name>
<url-pattern>/diagapp</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Logoff</servlet-name>
<servlet-class>com.brainsee.diagapp.Logoff</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Logoff</servlet-name>
<url-pattern>/logoff</url-pattern>
</servlet-mapping>
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>com.brainsee.diagapp.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>/diagapp/admin</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
diagnosesedit.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Diagnoseeditor</title>
</h:head>
<h:body>
<h3>Diagnosen</h3>
<h:form rendered="#{not empty diagnosisBean.list}">
<h:dataTable value="#{diagnosisBean.list}" var="diagnosis">
<h:column><f:facet name="header">ID</f:facet>#{diagnosis.id}</h:column>
<h:column><f:facet name="header">Text</f:facet>#{diagnosis.text}</h:column>
<h:column><f:facet name="header">Alternativname</f:facet>#{diagnosis.altname}</h:column>
<h:column><f:facet name="header">2. Alternativname</f:facet>#{diagnosis.altname2}</h:column>
<h:column><f:facet name="header">ICD-10</f:facet>#{diagnosis.icd10}</h:column>
<h:column><f:facet name="header">Alpha-ID</f:facet>#{diagnosis.alphaid}</h:column>
<h:column><h:commandButton value="edit" action="#{diagnosisBean.edit(diagnosis)}" /></h:column>
<h:column><h:commandButton value="delete" action="#{diagnosisBean.delete(diagnosis)}" /></h:column>
</h:dataTable>
</h:form>
<h:panelGroup rendered="#{empty diagnosisBean.list}">
<p>Table is empty! Please add new diagnoses.</p>
</h:panelGroup>
<h:panelGroup rendered="#{!diagnosisBean.edited}">
<h3>Add diagnosis</h3>
<h:form>
<p>Value: <h:inputText value="#{diagnosisBean.diagnosis.value}" /></p>
<p><h:commandButton value="add" action="#{diagnosisBean.add}" /></p>
</h:form>
</h:panelGroup>
<h:panelGroup rendered="#{diagnosisBean.edited}">
<h3>Edit diagnosis #{diagnosisBean.diagnosis.id}</h3>
<h:form>
<p>Value: <h:inputText value="#{diagnosisBean.diagnosis.value}" /></p>
<p><h:commandButton value="save" action="#{diagnosisBean.save}" /></p>
</h:form>
</h:panelGroup>
</h:body>
</html>
It's called in my DispatcherServlet just with
response.sendRedirect("admin/diagnosesedit.xhtml");
from a jsp file which is in the same directory.
WEB-INF/faces-config.xml:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<managed-bean>
<managed-bean-name>diagnosisBean</managed-bean-name>
<managed-bean-class>com.brainsee.diagapp.beans.DiagnosisBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
And the DiagnosisBean:
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import java.io.Serializable;
import java.util.List;
@ManagedBean
@ViewScoped
public class DiagnosisBean implements Serializable {
private List<Diagnosis> list;
private Diagnosis diagnosis = new Diagnosis();
private boolean edited;
@PostConstruct
public void init() {
list = DiagnosisDAO.getAll();
}
public void add() {
DiagnosisDAO.insert(diagnosis);
diagnosis = new Diagnosis();
}
public void edit(Diagnosis diagnosis) {
this.diagnosis = diagnosis;
edited = true;
}
public void save() {
DiagnosisDAO.update(diagnosis);
diagnosis = new Diagnosis();
edited = false;
}
public void delete(Diagnosis diagnosis) {
DiagnosisDAO.delete(diagnosis);
}
public List<Diagnosis> getList() {
return list;
}
public Diagnosis getDiagnosis() {
return diagnosis;
}
public boolean isEdited() {
return edited;
}
}
In my dependencies, Mojarra-1.2 and javax.faces:javax-faces-api:2.2 are included under the "Provided" scope (changing that to "compile" doesn't change anything).