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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:13:31+00:00 2026-06-11T06:13:31+00:00

I have: A managed bean called LoginBean. A JSF page called login.xhtml In this

  • 0

I have:
A managed bean called “LoginBean”.
A JSF page called “login.xhtml”

In this jsf page, i have a login form.

Inside the managebean i have a loginCheck function.

public void loginCheck(){
 if(logincorrect){
  //set user session 
 }else{
  //set lockout count session ++
 }
}

What i want to do in my jsf page is that when the lock out count session == 2 (means users failed to login correctly 2 times, i need a recaptcha tag to be displayed.

<td>
    <%
         if(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("numberOfLogins") == 2){
         <p:captcha label="Captcha" requiredMessage="Oops, are you human?"/>
       }
     %>

Apparently, the <% tag does not work. Appreciate any help from java/jsf experts.

  • 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-11T06:13:32+00:00Added an answer on June 11, 2026 at 6:13 am

    Scriptlets (those PHP-like <% %> things) are part of JSP which is deprecated since JSF 2.0 in favor of its successor Facelets (XHTML). Facelets doesn’t support any alternative to scriptlets anymore. Using scriptlets in JSP has in almost all cases lead to badly designed and poorly maintainable codebase. Forget about them. Java code belongs in fullworthy Java classes. Just prepare the model (some Javabean class) in the controller (a JSF backing bean class) and use taglibs and EL (Expression Language, those #{} things) to access the model in the view.

    Your concrete use case,

    <%
         if(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("numberOfLogins") == 2){
         <p:captcha label="Captcha" requiredMessage="Oops, are you human?"/>
       }
     %>
    

    can be solved in fullworthy JSF/EL as follows:

    <p:captcha label="Captcha" requiredMessage="Oops, are you human?" rendered="#{numberOfLogins == 2}" />
    

    That numberOfLogins can by the way much better be made a property of a JSF @SessionScoped @ManagedBean than some attribute being manually placed in the session map.

    See also:

    • Our JSF wiki page – contains some links to decent JSF tutorials as well
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a session scoped managed bean called MyController. It has a reference to
i have an managed bean(session scope) like this: class Home {// as homeBean public
I'm using JSF 2.0. I have a managed bean which I can access through
I am using JSF and spring . I have a spring managed bean in
I have a page that is backed by a ViewScoped Managed Bean. The page
I'm using JSF 2.0 with GlassFish 3.0. I have the following Managed Bean: @ManagedBean
I have this managed bean which makes SQL queries to Oracle database and returns
i have a page called page1.jsf which contains one parameter. i have a command
Title pretty much says it all. I have a page called login.jsp: <f:view> <html>
I have a managed bean called: @ManagedBean(name=configBean) @SessionScoped public class configBean implements Serializable {

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.