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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:36:35+00:00 2026-05-29T06:36:35+00:00

I am creating a Java EE web service application. I am not sure on

  • 0

I am creating a Java EE web service application. I am not sure on how to implement login:

Is it better for login to be implemented in a JAVA EE web service application by storing the UserPrincipal in the SessionContext and retrieving it every time a method is called programmatically to use

e.g say customer A buys a product, is it good programming practice to store the UserPrincipal in SessionContext, and retrieve the userid from it to use in the transaction,

or,

is it better to pass a token every time for each transaction and store all users logged in and the tokens issued in a table, so that when the purchase is done, the token can be used to retrieve the user id?

  • 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-05-29T06:36:36+00:00Added an answer on May 29, 2026 at 6:36 am

    The most common way is to login once, authenticating user info (uname, password)with db,
    then saving in a session the users data or the user role (for example, with session scoped bean).

    That way the user data\ user role is persisted and is accessible when you need it (server side or client side)

    public class UserSession implements Serializable {
    
        // login-related fields
        protected String  userName;
        protected String  userPassword;
        protected Object  requestInfo;
    
    
        //session related info
        private Object sessionInfo ;
        private boolean loggedIn;
        /** This method tries to login the user 
        */
        private login (userName,password){
        loggedIn = callDbAndAuthenticateUser(userName,password)
        } 
    

    Define that bean scope to session, and update it on the session

    In another bean or directly from the jsf page check the getter isLoggedIn to know if the user is logged.


    Edit

    You use ejb\rmi when you access the database.Those issues are not necessarily the same\related,

    you can pass the credentials to the method you invoke remotely, or you can handle authorization at your local server and let your local authentication mechanism invoke the remote method.

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

Sidebar

Related Questions

I am creating a new web service for an application and am currently designing
I'm creating a web service in Java that will be consumed by an external
I'm tasked with creating a Java Web Service for a .NET 2.0 client to
I am having trouble creating a Web Service in Java that contains two methods
I am creating a Java service which will run within a web servlet container
Application configuration: Web application using java first method of creating JAX-WS 2.0 Web Services
I am new to creating Java web applications and came across this problem when
We're creating a web system using Java and Servlet technology (actually Wicket for the
Firefox 3.5 does not allow creating java OBJECT tag with Javascript (document.write)? this technique
I've creating a Java Swing application and I realized that I have many many

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.