By Ian Stallings
In the last article we made a basic hello world Java object that we could interact with using ASP. If you have not read that article I recommend you check it out before reading further. This time we're going to really dig in and build a cool object that will grab a string on another site using the URL.
Ok, First thing we do is create the
.java source file. Hopefully this will help
it should be pretty easy. Please read the comments in the code to get a better
understanding of Java.
The code for class is available in text format.
You then go to the command line again and compile the
just like we did the last one. Once that file is compiled place the
StringGrabber.class file in the
You can now access it from an ASP file.
Next, Let's create the ASP file using this VBscript:
This should go directly to Nasdaq's website and grab the newest stock price for
the stock entered based on the ticker symbol. The string is found by parsing the web
page and looking for the first
<b>$ it finds. It then looks for the next
take whatever's inbetween. This function can be altered greatly to get any string you want. Say
the headlines from a news site, the weather, etc. You can change the web page it uses by
Now let me make a note before I get anyone in trouble. Taking material from a site without permission can be seen as a copyright violation, So I don't advise taking any info from any site without permission. Especially Nasdaq. Unless you like tangling with the super-congolomo with extremely deep pockets type.
I have to give credit to Frank Leahy from Wired for his article on using IIS extensions in Java. Without his help I wouldn't have been able to write this article.
StringGrabber.javain text format
StringGrabber.aspin text format
Ian Stallings is a 26 year old Software Engineer from the Washington DC area. He has experience in Internet/Intranet development using ASP, VB, Java, SQL Server, and IIS. Prior to devoting his career to application development he worked as a systems administrator at a small ISP.
When not developing applications or tinkering with computers, he masquerades as a normal human being