Results 1 to 2 of 2
  1. #1
    Tim99 is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default How to get IP for SessionScoped Bean?

    Hi,

    I have a user bean that looks like this (simplified).

    Java Code:
    @Named
    @SessionScoped
    public class User implements Serializable {
      
      final String IP_ADDR = "1.2.3.4";
    }
    Now I'm stuck and don't know how to initialize the field. Of course, ID_ADDR doesn't have to be a string. Is there any standard-way for doing this in JSF-servlets? Any help is greatly appreciated!

  2. #2
    nicephotog is offline Member
    Join Date
    Mar 2012
    Posts
    41
    Rep Power
    0

    Default Re: How to get IP for SessionScoped Bean?

    What i find weird is you made it a "constant" final, which can only be initialised at bean loading instance.
    Of the initializing, you could write the field into the backing beans faces-config.xml declaration tag with its data type and value.
    If you didn't make it final you could set it with a public void set bean method.

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2011, 08:55 AM
  2. any way to communicate one bean to another bean not using session in jsf
    By MayaKannan in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 01-14-2011, 02:45 PM
  3. UREGENT-accessing session bean ok but entity bean
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-28-2008, 02:34 PM
  4. Replies: 0
    Last Post: 03-30-2008, 11:03 AM
  5. Replies: 0
    Last Post: 09-26-2007, 09:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •