user206646
user206646

Reputation: 191

Prevent access to java web application other than localhost

I have a web application running in jetty. I have to provide a configuration, like when the flag is set true access should be granted to users access the web application through ip instead of localhost. If the flag is not set to true, then the request other than localhost should be denied. How to do this?

Thanks.

Upvotes: 1

Views: 212

Answers (1)

Kartoch
Kartoch

Reputation: 7779

If you want to do this from your application (not changing jetty configuration), you can write a filter servlet for your application, and using ServletRequest#getRemoteAddr() to know where come from the request.

Upvotes: 1

Related Questions