I wants to know how i can retrieve the entered web address in browser from my java code ?, Is there any specific API or how i can monitor http trrafic? so that from there i can get every entered url in browser.
Are you working with a bare socket, an applet or a servlet? The applet class has methods to get the URL it is loaded from. Servlets have a request object that has methods to obtain the request path.
I am working with a bare socket, actually i have a simple program which runs as a service in the background , i wants that program to get the every url that user enters in his/her browser.
Safi Khan wrote:I am working with a bare socket, actually i have a simple program which runs as a service in the background , i wants that program to get the every url that user enters in his/her browser.
It sounds like you're trying to write a proxy server. Or at least, let me put it this way, if you did write a proxy server then it would naturally get every URL that the user entered in the browser. Provided that you configured the user's browser to connect via your proxy application.
In fact it would get every URL which the browser tried to connect to, regardless of whether the user entered it in the address bar or not.
But I think it would be helpful if you backed up a few steps and explained the background of this question. Right now it's unclear why you want to get URLs entered into the browser, and what your service has to do with that requirement.
Joined: Aug 11, 2012
Thanks for the reply (Paul Clapham)
Here is the clarification,
I am not writing a proxy server, Actually i have a java program/service which has a list of predefined url's, now i wants my program to stop the user access to these url's from browser. So for this i need the entered url in browser so that i can compare and do my actions.
I am thinking about, how i can hava a socket which should start listening data from the browser socket so that when browser sends the http request, i should also get that object, Is it possible or any other idea.
Well, that's why you would use a proxy server. The proxy server inspects all requests from the browser and either passes them on to the web, or rejects them by sending a response itself. I'm posting this from my browser through a proxy server which does exactly that -- it doesn't block the Ranch, but it does block e.g. Facebook.