File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to restrict access to request from specific IP’s in Java web application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to restrict access to request from specific IP’s in Java web application? " Watch "How to restrict access to request from specific IP’s in Java web application? " New topic
Author

How to restrict access to request from specific IP’s in Java web application?

cherry hal
Greenhorn

Joined: May 06, 2012
Posts: 10
How to restrict access to request from specific IP’s in Java web application?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Note that the javax.servlet.ServletRequest interface has a getRemoteAddr method.

Bill

cherry hal
Greenhorn

Joined: May 06, 2012
Posts: 10
Hi William Brogden,
Thank you and can you explain with programmatically i mean sample code?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

You have enough info to write some code for yourself. Please do so and then post back with any troubles you may be having.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

One suggestion - use a filter to check the IP address. That way you don't have to build in the same checks in all of your servlets.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
cherry hal wrote:Hi William Brogden,
Thank you and can you explain with programmatically i mean sample code?


If you are aspiring to be a servlet/jsp developer, you will learn more by coding than by asking for worked out code.
 
Consider Paul's rocket mass heater.
 
subject: How to restrict access to request from specific IP’s in Java web application?