Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi team!

I'm working on a small (i hope so) project and I'm in a very begginning. I've googled around and still couldn't get started. Let me explain my idea. First I type a website's address (let say codeproject.com) in a JTextField. Then after hitting on a JButton (let say Block), I can't open that site using internet browser (firefox actually). But after hitting another JButton (let say Unblock), I can normally access the website. I've just known that it's difficult to do this using java. Using C++ is maybe a better choice. My system is windows 7 and my project seems to be a filter. Let say you have a black list and don't want any access to websites from that list.

Any advice would be appreciated!

Thanks in advance!
Posted
Updated 7-May-12 2:59am
Comments
Manfred Rudolf Bihy 7-May-12 6:40am    
Are you talking about blocking the access only on localhost or is it for a whole network of computers?
What OS are you targeting?

Please add the information to your question by using the Improve question link!
Manfred Rudolf Bihy 7-May-12 6:40am    
Reason for my vote of 3
Please add more information to your question!

1 solution

1. On WindowsXP and upward one very easy way to achieve what you want would be to add entries to your hosts file to point certain domain names to localhost. See here: http://answers.yahoo.com/question/index?qid=20080120053857AAqCQgE[^].
There is no need to reboot since upward from Windows9x the changes are immediate. It might be nescessary to resart IE since I've read somewhere that IE caches name lookups.
Remember though that his will block the whole domain. It is not possible to only block certain applications or websites that live under that domain.

2. Use a proxy on your machine and preferably one written in Java. You can easily make some modifications so it can react to messages sent from your application to block or unblock a certain URL. Here a nice list of Open Source Proxies that are all written in Java: http://proxies.xhaus.com/java/[^]

Regards,

Manfred
 
Share this answer
 
Comments
svatstika 7-May-12 8:57am    
Well, I've tried your first suggestion but that is not what I'm looking for. The second one is also the same thing in terms of coding. I want to know if Java can do that by coding. Anyway, thank you for your help. And if you have any idea please let me know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900