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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:13:04+00:00 2026-06-15T04:13:04+00:00

How to implement j_security_check with Primefaces ? Normally in JSP if you want to

  • 0

How to implement j_security_check with Primefaces? Normally in JSP if you want to use JAAS for login, the login form generally is:

<form action="j_security_check" method="POST">
   Username:<input type="text" name="j_username"><br>
   Password:<input type="password" name="j_password">
   <input type="submit" value="Login">
</form>

But how do we implement it in JSF or in Primefaces!

  • What will be the action
  • How do we get rid of id or name like formId:componentId
  • Also the p:commandButton is ajaxified in Primefaces by default, so how does it
    submit the form in non-ajax way

I had a requirement to implement the JAAS form authentication with Primefaces and I am sharing the solution here; it might come handy to someone.

  • 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-15T04:13:05+00:00Added an answer on June 15, 2026 at 4:13 am

    The solution is pretty straightforward.

    • You need to define the h:form with prependId="false", so that it will not generate id or name of the component as formId:componentId.
    • You need to defined the action="j_security_check" in the h:form as onsubmit="document.getElementById('login').action='j_security_check';"
    • Set the ajax attribute of the p:commandButton to false, so that the form doesn’t get submitted in ajax way.

    That’s it. Here is the complete code of the login form which can be replaced by the aforesaid form:

    <h:form id="login" onsubmit="document.getElementById('login').action='j_security_check';" prependId="false">
        <h:panelGrid columns="2">
            <p:outputLabel for="j_username" value="Username" />
            <p:inputText id="j_username" name="j_username" />            
            <p:outputLabel for="j_password" value="Password" />
            <p:password id="j_password" name="j_password"/>
            <p:commandButton id="submit" value="Login" ajax="false"/>
        </h:panelGrid>
    </h:form>
    

    Thanks.

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

Sidebar

Related Questions

I'm trying to implement a simple form-based login for my web application deployed with
I'm trying to implement OpenID authentication in a simple JSP app. The FORM -based
I'm trying implement a custom login page to use in my JSF 2.0 application.
I am trying to implement web services that use different security mechanisms to do
I implement notifications in my IOS app, and I use customized sounds. Everything works
I'm trying to implement the configuration but it never redirects me to my login.html
I get the username of the connected user (using j_security_check) this way, through a
I have a form on my .jsp page which sends a password back to
I am trying to implement privileges using NHibernate, and what I want to do,
I want to implement role-based access control for each button and function in my

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.