An example may also help:
1st page is http://www.myhost.com. On that page is a link, <a
href="news">News</a>, which dynamically displays the links to a list
of news stories. These links are relative to news, <a
href="story.html">Story<a/>. Therefore, absolute URL for story.html is
http://www.myhost.com/news/story.html. Clearly I could use getHost()
getPath() to build this link, but the problem comes when story.html
contains links that are also relative to news.html. Now getPath()
returns "/news/story.html", not just "news".
Thanks,
Jack
j_m...@yahoo.com
Have you tried String.lastIndexOf('/') ? That is the usual approach to
splitting a file name from a path.
--
Paul Lutus
www.arachnoid.com
[omoore@okmoore tmp]$ java Test http://www.seg.org/index.html
http://www.seg.org
[omoore@okmoore tmp]$ cat Test.java
public class Test
{
public static void main(String args[])
{
//in your case, this would set 's' to the full URL
String s = args[0];
//store only the path in the 'path' variable
String path = s.substring(0,s.lastIndexOf("/"));
//prin out the path
System.out.println(path);
}
}
--
Ossie J. H. Moore
ossie...@home.com
Online JDK documentaiton:
http://java.sun.com/j2se/1.3/docs/api/index.html
Give Star Office 6.0 Beta a try...
http://www.sun.com/staroffice/6.0beta/
How about using the constructor
new URL(documentURL,"somepage.html");
?
BK