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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:21:10+00:00 2026-05-31T21:21:10+00:00

I have a simple question, but I’m searching for longer time, but I always

  • 0

I have a simple question, but I’m searching for longer time, but I always found the same answers,which i don’t really know how to handle…

i want to get the IP adress of the client, when he registers to my application…

i found something like this:

    @ManagedBean(name="testController")
    @SessionScoped
    public class TestController implements Serializable {

        private static final long serialVersionUID = -3244711761400747261L;
        protected final HttpServletRequest req;

        public TestController(HttpServletRequest req) {
            this.req = req;
            System.out.println(this.req.getRemoteAddr().toString());
        }
    }

but i don’t have the HttpServletRequest in the constructor….
or i don’t know how to use it, all i get are errors….

  • 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-31T21:21:11+00:00Added an answer on May 31, 2026 at 9:21 pm

    It’s available by the ExternalContext#getRequest().

    public TestController() {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        System.out.println(request.getRemoteAddr());
    }
    

    Note that you’re making one major conceptual mistake in your initial attempt. You’re attempting to assign the current HTTP request as a property of a session scoped managed bean. The HTTP request instance will expire by the end of the current HTTP response and thus not be valid anymore and throw exceptions in all colors when you try to access its methods in the subsequent requests following the initial request when the session scoped bean was been created.

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

Sidebar

Related Questions

I have a simple question, but searching on the internet didn't help me (maybe
I have a simple question. Of course it has many answers but I cannot
I use spring 3.0 and I have a really simple question but didn't find
I have a rather simple question and I have found several answers to this
Simple question but it's really causing me problems! I have a var dump as
Sorry guys for the really simple question but I have tried to float one
this sounds like a really simple question but could easily have a very complicated
Maybe a simple question but I really don't know what to do. When I
I have a pretty simple question but I am really new to php. I
a simple question but I don't seem to have the right terminology to search

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.