Click to See Complete Forum and Search --> : Absolute and Relative Links


Scott MacMaster
September 27th, 1999, 06:15 AM
I have a drop down control and the items in it are links. The code I have to do this will work for absolute links like http://www.winzip.com:

String url = "http://www.winzip.com";
try { theURL = new URL(url); }
catch ( MalformedURLException e)
{
System.out.println("Bad URL: " + theURL);
}
getAppletContext().showDocument(theURL);



but it work work for relative links:

String url = "index.html";
try { theURL = new URL(url); }
catch ( MalformedURLException e)
{
System.out.println("Bad URL: " + theURL);
}
getAppletContext().showDocument(theURL);



Does anyone know why it won't work or how to get it to work?

Scott
Give a man a fish and feed him for a day,
Teach a man to fish and feed him for life.
_______________________________________________________
http://welcome.to/scottweb - The Ultimate Programmers Reference

January 18th, 2000, 07:57 AM
I think this will work:

try {
URL mainURL = new URL("http://www.winzip.com");
String rel = "index.html";
URL theURL = new URL(mainURL, rel);
} catch (Exception e) {
// anything
}