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 7986123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:45:36+00:00 2026-06-04T11:45:36+00:00

I am creating a user authentification in JSF2, and my header displayed on every

  • 0

I am creating a user authentification in JSF2, and my header displayed on every page contains this:

<c:if test="#{user.loggedIn}">
    <li><h:link value="Log out" outcome="#{user.logout}"/></li>
</c:if>

User refers to the userBean, and logout() simply invalidates the session, and issues a redirect to the login page. So when the user logs in, user.loggedIn becomes true, and logout link gets displayed, but it somehow immediately gets called, and the user is immediately logged out.

Does anyone have an idea why is this happening? I thought of using h:commandLink, but it requires a form, and I’m trying to avoid it.

Edit:
I copied the wrong code… just my luck after spending an hour figuring out why the user cannot login. You can look at the previous revision to see miscopied code.

  • 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-04T11:45:38+00:00Added an answer on June 4, 2026 at 11:45 am

    That can happen when the JSF tags are not recognized and parsed as such and it effectively get rendered as plain text wherein all EL expressions are evaluated as value expressions. It would in your case basically print the returned value of #{user.logout()}. But while EL does that, the method’s logic is of course invoked.

    If you remove the action attribute and open the page in browser and do a View Source, then you’ll see an unparsed <h:commandLink> tag instead of the generated HTML <a> element.

    Make sure that you have the h: XML namespace definied on the right URI in the root tag of the view file.

    xmlns:h="http://java.sun.com/jsf/html"
    


    Update: the <h:link> isn’t intented to invoke bean actions. It’s intented as a pure GET link. The outcome is per specification evaluated as a value expression, not as a method expression. The outcome must represent a view ID where the link has to navigate to. When the EL evaluates your method as a value expression, it’s of course immediately invoked. Just keep using <h:commandLink> in combination with a redirect. Additional advantage is that this isn’t bookmarkable nor searchbot-crawlable.

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

Sidebar

Related Questions

Given that you're creating a User Control in WPF that will be displayed on
I am creating a user input at one of the events: var throwConnectBox =
I'm currently creating a user interface using WPF and would like to display a
We are creating a user interface that functions on a wide variety of platforms
I am creating an user registration form using jsp,in which there is an option
I've created my own signup form and creating the user using the Membership class.
I have such view that handles user registration. After creating new user i want
Is there an RFC, official standard, or template for creating a User Agent string?
Situation: I am creating a database user interface for a client's website. I know
Was wondering if anyone had any smart approaches to creating dynamic vanity user urls

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.