0

I am trying to use the new Java EE 8 security.

It is working if I don't use JSF in the login page. If I use JSF, nothing is displayed because the form is inside a <h:form> tag (a JSF tag). The EL expressions of the page outside of the form are displayed "#{bean.property}" and not with the value of the property.

If I type directly the URL of the login page in the browser, the page is correctly displayed. It is not displayed correctly if the page is displayed when I try to access a protected page.

I tried with Chrome and Firefox. I had to add an exception because of the "https" added by Java EE for the URL of the login page. Is it the problem?

The application uses Payara 5.182.

The code of the page:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/formations/templateBase.xhtml">
<ui:define name="title">
  <h:outputText value="#{bundle.Login_Titre}"></h:outputText>
</ui:define>
<ui:define name="content">
  #{'HELLO!'} <!-- JUST TO TEST -->
  <h:form id="form">
    <p><h:outputText value="#{bundle.Login_Message}"/></p>
    <h:outputText value="#{bundle.identifiant}"/>
    <h:inputText id="login" value="#{loginBean.name}"/>
    <h:outputText value="#{bundle.password}"/>
    <h:inputSecret id="password"
                   value="#{loginBean.password}"/>
    <p><h:commandButton value="#{bundle.Login_Login}" action="#{loginBean.login}"/></p>
  </h:form>
  </ui:define>
  </ui:composition>
 </html>
user1643352
  • 2,635
  • 2
  • 19
  • 25
  • Sorry, your problem description is totally unclear to me – Kukeltje Sep 14 '18 at 14:49
  • Kukeltje, what information is missing so that the problem is clearer to you? – user1643352 Sep 14 '18 at 22:32
  • I have just edited my question (`` was not displayed correctly). – user1643352 Sep 14 '18 at 22:39
  • The whole description is unclear. _" If I use JSF, nothing is displayed because the form is inside a tag (a JSF tag). "_ is very weird. And what you mean by each of the next two paragraphs is hard to undetstand. – Kukeltje Sep 15 '18 at 08:13
  • BalusC: Thanks a lot (I am reading your last book about JSF in Java EE 8 and I like it a lot). The problem was the FacesServlet mapping (/faces/*). So, for now I have added "/faces" in front of the value of my loginPage in @CustomFormAuthenticationMechanismDefinition. I have tried to change the FacesServlet mapping to "*.html" as you advise to do it in your book and it works too. – user1643352 Sep 15 '18 at 16:22
  • Kukeltje: If my login page uses JSF, the JSF tags are not understood by the browser. All the contents of is not translated to HTML (because the URL of the page does not match the ServletFaces mapping) and so nothing is displayed in my login page. BalusC has just answered my question which was a special case of a more general question i did not find. – user1643352 Sep 15 '18 at 16:28

0 Answers0