Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9139033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:20:05+00:00 2026-06-17T09:20:05+00:00

I’m new to JSF and Primefaces and have just started working on logging in

  • 0

I’m new to JSF and Primefaces and have just started working on logging in and basic navigation and I have run into a problem already. I’ve gone through about 10 similar questions here on SO and none of the solutions has worked for me yet so I figured I would post up my specific problem so that someone who really knows can point me in the right direction.

  1. Logging in: seems to work just fine as does logging out but I’m concerned because the url in the browser still says that I’m at the login screen after logging in and I used the login example straight from the Oracle EE6 docs. Login method is provided below.

    public String login(){
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
    try{
        logger.log(Level.FINE, "User credentials: name: {0}, password: {1}", new Object[] {this.username, this.password});
        request.login(this.username, encrypt(this.password));
        logger.log(Level.FINE, "User: {0} logged in", this.username);
    }catch(ServletException e){
        logger.log(Level.SEVERE, "User: {0} login failed, password: {1}", new Object[]{this.username, encrypt(this.password)});
        context.addMessage(null, new FacesMessage("Login Failed!"));
        return "error";
    }
    return "/faces/system/index";
    

    }

  2. After logging in I’m taken to the correct page in the correct directory and everything is being displayed corectly but when you hover over the links the status bar at the bottom of the browser displays the same url for all three links. Code for the page provided below.

        <h:body>
        <p:layout fullPage="true">
            <f:facet name="last">
                <h:outputStylesheet library="css" name="discovery.css"></h:outputStylesheet>
            </f:facet>
            <p:layoutUnit styleClass="headerDiv" position="north" size="100">
                <h:graphicImage library="images" name="header.jpg"></h:graphicImage>
            </p:layoutUnit>
            <p:layoutUnit styleClass="navDiv" position="west" size="200" id="navPanel">
                <h:form>
                    <h:outputText value="Navigation Menu"></h:outputText>
                    <br/>
                    <p:commandLink value="First Time Users" update=":main">
                        <f:setPropertyActionListener target="#{navigationBean.pageToDisplay}" value="tutorial.xhtml"></f:setPropertyActionListener>
                    </p:commandLink>
                    <br/>
                    <p:commandLink value="Help" update=":main">
                        <f:setPropertyActionListener target="#{navigationBean.pageToDisplay}" value="help.xhtml"></f:setPropertyActionListener>
                    </p:commandLink>
                    <br/>
                    <h:commandLink action="#{loginBean.logout()}" value="Log Out"></h:commandLink>
                </h:form>
            </p:layoutUnit>
            <p:layoutUnit position="center" id="main">
                <ui:include src="#{navigationBean.pageToDisplay}"></ui:include>
            </p:layoutUnit>
        </p:layout>
    </h:body>
    
  3. The NavigationBean

    @Named(value = “navigationBean”)
    @RequestScoped
    public class NavigationBean implements Serializable {

    public NavigationBean() {
    }

    public String getPageToDisplay() {
    return pageToDisplay;
    }

    public void setPageToDisplay(String pageToDisplay) {
    this.pageToDisplay = pageToDisplay;
    }

    private String pageToDisplay = “welcome.xhtml”;
    }

When the page loads after logging in the default page set in the navigation bean is displayed but clicking on any link other than the log out link causes the default page to disappear from the center layout unit and a blank page is displayed/ Clicking on the log out link does log you out like intended though. ANy help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:20:06+00:00Added an answer on June 17, 2026 at 9:20 am

    1. Logging in: seems to work just fine as does logging out but I’m concerned because the url in the browser still says that I’m at the login screen after logging in.

    Send a redirect (this instructs the browser to send a new GET request on the given URL, which get reflected in browser’s address bar).

    return "/faces/system/index?faces-redirect=true";
    

    2. After logging in I’m taken to the correct page in the correct directory and everything is being displayed corectly but when you hover over the links the status bar at the bottom of the browser displays the same url for all three links.

    The <h:form> indeed submits to the very same page. Use <h:outputLink> or <h:link> instead of <h:commandLink> for page-to-page navigation. See also When should I use h:outputLink instead of h:commandLink?


    3. When the page loads after logging in the default page set in the navigation bean is displayed but clicking on any link other than the log out link causes the default page to disappear from the center layout unit and a blank page is displayed

    This is solved by using GET instead of ajax postback for page-to-page navigation. So, it’s inherently solved when solving #2. You might only want to redesign your NavigationBean to be a filter or phase listener which also intercepts on GET requests. You shouldn’t be navigating by POST at all. It defeats bookmarkability, user experience and SEO, exactly as you’re encountering now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have been unable to fix a problem with Java Unicode and encoding. The
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.