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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:02:11+00:00 2026-06-12T00:02:11+00:00

I have a Java servlet application running within Tomcat, there is one admin command

  • 0

I have a Java servlet application running within Tomcat, there is one admin command that I only want to be able to run from the machine itself (or possibly my own pc as well) for security reasons. So to enforce this I check the remote address of the HttpServletRequest that I receive but it always returns 127.0.0.1 even though the request is not coming from the local host

Why is this, can I fix it or is there an alternative way to run my admin command only from the server.

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

    First check if the request has the ‘X-Forwarded-For’ header. If the header is set, the first IP in it should be the one you’re looking for. If the header is empty request.getRemoteAddr() should return the correct IP.

    Wiki for ‘X-Forwarded-For’: http://en.wikipedia.org/wiki/X-Forwarded-For

    Note that you cannot be 100% sure that you get the correct IP like this since forwarding instances are not forced to set the ‘X-Forwarded-For’ header.

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

Sidebar

Related Questions

I have a Java web application running on Tomcat. I want to load static
I have a simple tomcat servlet application, no Java EE. Also, I am running
I have web application written in java using Eclipse. It has just one servlet
Our application is a Java-GWT application that uses Guice-Persist and Guice-Servlet extensively. We have
I have a web application running on Tomcat 6 and a Java-programmed client application.
I have an application which is running on tomcat, one of the methods is,
We have a Java web application (app #1) running under Tomcat. Our requirement: We
I have a java application 'JA' and a Java project containing a servlet project
I have a Java servlet that receives data from an upstream system via a
I have this java servlet that grabs information from a form, I need 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.