• Post Reply Bookmark Topic Watch Topic
  • New Topic

Differentiate request from intranet and internet  RSS feed

 
Rahim Vindhani
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm developing an application which would require access restriction based on the IP address.

Basically, the JSP page needs to be accessed only by local intranet users. If the request comes from outside local network, the page should not display the content.

Any help, suggestions would be highly appreciated.

Thank you.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletRequest provides the getRemoteAddr method which returns the client's IP.

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getRemoteAddr()

You could write a filter that denies requests from IPs that don't start with 192.168. or 10.10. or whatever your subnet IPs start with.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!