Start Search Contents Index Links About

Bookmark utility part 2 - Get page title

HTML download

2002 - Week 8 - Havard Rast Blok

Last week we made a small program that could receive dropped objects. If you tried to drop an URL from Netscape or Explorer over this application, you probably noticed that only the URL appeared. So it would be nice to get the title of the page as well. This week you can implement such an application.

If you looked at the tasks from week 48 last year, you would get a free ride this week. If not, please review that page for information on how to download an URL.

Now that you have the HTML source code, it should be fairly easy to extract the title. Examine the heading of the file, and you will find the <TITLE> tag and </TITLE> end tag. It is of course the text in between that you are interested in.

Make a small application that accepts an URL as a parameter on the command line and outputs the title of the page. If no title tags are found, it should yield so.


GetTitle.java

Finally, this week, you could now combine the feature above with last week's drag and drop actions. When an URL is dropped into your application, both the URL and the title would be shown.



site: Håvard Rast Blok
mail:
updated: 27 July 2007