Click to See Complete Forum and Search --> : how to capture URL address from IE browser ?
omati
03-29-2005, 04:41 AM
hello
how can i capture the url address from the IE browser when i type it in the address bar using java ?
for example when i type http://www.yahoo.com in address bar
how can i capture it, to save it in text file using java?
i need a simple example plz ...thanks.
buntine
03-29-2005, 04:53 AM
This is a simple way that I use when I need to:
String fileName = request.getRequestURI();
if (request.getQueryString() != null) {
fileName += '?' + request.getQueryString();
}
URL generatedURL = new URL(request.getScheme(),
request.getServerName(),
request.getServerPort(),
fileName);
out.println(generatedURL.toString());
It first determines whether there are any QueryString parameters -- if there is then they are appended to the string. Then it generates the URL by constructing a URL object. You can print the URL via the generatedURL.toString() method.
Note, I hope you meant Java (JSP) and not JavaScript...
Regards.
omati
03-29-2005, 09:55 AM
thank u for helping
yes i mean java..
but when i compile the code it gave me error in import jar ?!
which packege jar should be used ?
import java.* ?
and from where to download the packege
also
the code :
request.getRequestURI(); // undefine to me
request refer to which method ?
i use java creater pro software to compile my code and my library in
this directory c:/j2sdk1.4.0.
can u plz give me full code example, include the main class
beacuse i face many problem & i should submit my final project on 29/4 .
buntine
03-29-2005, 07:32 PM
You need to import the net package.
import java.net.URL;
Its considered bad practise to simple include an directory or set of directories. You should really just import the class.
Regards.