473,327 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Block a IP Address in JSP

I have designed a application in JSP. In which i want to block few ip address and display a message to the particular user that you have been banned to view this site.
Thanks & Regards in Advance
Dec 17 '09 #1
5 6861
chaarmann
785 Expert 512MB
Congratulation to your achievement. Do you like to show us the design you have done?
Maybe we can learn from it if you post it under forum "insights".
Dec 17 '09 #2
chaarmann
785 Expert 512MB
What's the problem here? Nothing?
Ah, I see ...
Congratulation to your achievement. Do you like to show us the design you have done?
Maybe we can learn from it if you post it under forum "insights".
Dec 17 '09 #3
Frinavale
9,735 Expert Mod 8TB
You can retrieve the client's IP address using the request object.
For example:
Expand|Select|Wrap|Line Numbers
  1. out.print( request.getRemoteAddr() );
  2. out.print( request.getRemoteHost() );
  3.  
Please be aware that there may be more than one user with the same IP address because they could be on the same network.

-Frinny
Dec 17 '09 #4
chaarmann
785 Expert 512MB
Dear Frinny,
I have done a JSP-page for a customer using these commands once. (To be precise, Not to block the client's IP address, but to write it to a log file only). It turned out that I only got 2 different IP addresses in my log from thousands of requests!!! I figured out that these addresses belonged to the 2 proxy servers of the company!
That means even if your company has no proxy server, the client may have: his company, his ISP, or one of the global servers in the routing table .That has the effect that if you block one IP-address, you also block thousands of other users.
So this solution is not usable. As far as I know you can only block a user by providing a username/password login mechanism for everyone and then disabling his account.

But maybe there is a solution I don't know of to get the sender's IP address (Something like tracert or email-header functionality). Maybe something new with the JDK6 or SSL-connection?
But even then I would not block longer than 10 minutes. Once the user sees he is blocked he would simply cancel the connection to his internet provider and log on again to get a new IP address automatically. (and some other new poor guy who just happened to log on the same time gets the reused old IP address and is blocked for the rest of the 10 minutes! (which is not good, but better that being blocked for the rest of his life :-))

So I am eager to see the OP's (Naveenkongati) design he claims to have done.

Or, Frinny, is there a way to get the client's MAC address (the unique number of his network card) somehow?
Dec 18 '09 #5
Frinavale
9,735 Expert Mod 8TB
You are quite right chaarmann. That is why I mentioned that there may be more than one user with the same IP if they're on the same network (or using the same proxy).

You can't get the MAC address through typical web requests.

A better approach would be as you suggested, block the user based on their login information (ie: user name and password) as apposed to blocking an IP.

-Frinny
Dec 18 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mark | last post by:
Is there anyway I can set up a personal 'remailer' type of thing on my domain ? I can not email a friend at his workplace because his company have put a 'block' on emails from my work address...
14
by: pcchong | last post by:
I use a free database-driven ASP guestbook. I want to add a IP address blocking filter to it( just to block one particular guest). What is the easiest way to do so? Thanks. pcchong
18
by: Michal Mieszkowski | last post by:
i have a block of html code looking like this <FORM name=myform> <INPUT type=text name=firstname> <DIV id=mydiv> <INPUT type=text name=address> </DIV> </FORM> i can access firstname field...
9
by: Timo | last post by:
I'd be grateful for some help on this element addressing question. I want to change the font-size of the "H" of "Hello World" in the following HTML using first-letter, but cannot "reach" the...
16
by: Alfonso Morra | last post by:
Hi, I am at the end of my tether now - after spending several days trying to figure how to do this. I have finally written a simple "proof of concept" program to test serializing a structure...
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
3
by: Nadav | last post by:
Hi I wonder... Is it possible to define the address to which shared memory will be mapped In other words is it possible to apriory define the address MapViewOfFile returns Dlls are being loaded...
12
by: Eric Lindsay | last post by:
I'm trying to learn how to read a DTD I wanted to use, http://www.w3.org/TR/html4/strict.dtd to ensure I was treating each element correctly in terms of being block, inline, or flow (either). ...
1
by: tankbattle | last post by:
That is, what's the difference between <complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.