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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:44:03+00:00 2026-06-14T00:44:03+00:00

Actually I’m new to JSF and Facelets and enterprise apps despite i’ve been working

  • 0

Actually I’m new to JSF and Facelets and enterprise apps despite i’ve been working on it the last 4 months, anyway, i’m developing a web page which has a login, an user administrator and a documents administrator (it has more but it doesn’t matter) and i have to manage the acces and the content of pages according to each user permissions. Reading about security i’ve found out many ways of doing a login, but i have made my own with Stateful Beans in order to maintain the users data in the application for using them later so i can restrict the content. the question is… is this the correct way to manage the content according to users restrictions?
if not, which is the best and securest way of doing it?

this is my Stateful Bean (i did not include the Getters and Setters)

    @ManagedBean
    @Stateful
    public class HandlerLogin implements Serializable{

    @EJB
    private LoginMethodsLocal loginMethods;

    private String loginNickname;
    private String loginPassword;
    private String userData[];
    //[0]=Nickname
    //[1]=Name
    //[2]=User Type

    private boolean loguedIn= false;

    public void check(){

    System.out.println(this.loginNombre);
    System.out.println(this.loginContrasena);

    this.userData= loginMethods.Login(this.loginNickname, this.loginPassword);
    //the method loginMethods.Login() queries in the database looking for
    //"this.loginNickname" and "this.loginPassword"

    if (this.userData!=null){

        this.loguedIn=true;

    }
    else{

        this.loguedIn= false;
        FacesContext.getCurrentInstance().addMessage("mensajesLogin", new FacesMessage("Error, User Does not Exist"));
    }
}

public void closeSession(){

    this.userData=null;
} 
}

so my logic to manage the content and navigation is to check what kind of user is and depending on it determine how the acces and rendering is going to be

  • 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-14T00:44:04+00:00Added an answer on June 14, 2026 at 12:44 am

    The @Stateful annotation does nothing in a JSF @ManagedBean. That annotation is only really been used when the class is by itself injected as @EJB in another managed bean or EJB and even then, a brand new and completely different instance with all properties set to default would have been created and used. So the @Stateful annotation definitely doesn’t do what you think it does. Remove it, it makes no sense in this context.

    Whether the remaining code is the correct way or not depends on the concrete functional requirements. There are many ways which are equally good and secure (assuming that you understand what code you actually are writing). The question is more: how many of the wheel do you want to reinvent yourself? The builtin container managed authentication leaves very little room for finegrained control, but if it is sufficient for you, then just make use of it instead of homebrewing the authentication yourself.

    Going through the following related answers should give some good ideas:

    • Performing user authentication in Java EE / JSF using j_security_check
    • JSF: How control access and rights in JSF?
    • How to check if is user logged in?
    • How to properly use isUserInRole(role)
    • JSF request scoped bean keeps recreating new Stateful session beans on every request?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually I am new to jquery as well as web designing Now I need
Actually I am working on this for the last 3 or 4 weeks but
actually, i'm developing a web template using ASP.NET and C#. i have a listview
Actually I am developing one application in that when application run first time it
Actually ,i am working on a livechat application its works fine.This application is tabbed
Actually i work on java web application using spring mvc 3 and hibernate 3.5
Actually I am working on the Couchdb .Till now i have used the Local
Actually I'm working on simple project MVC4 + EF in which I have relation
Actually, if you use a method with new, create, alloc or copy in it's
Actually i am working on a image editing software and now i want to

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.