By Ian Stallings
Using ASP you can do a lot of cool stuff. But when the page views go through the roof it's time to move your code over to a more robust and mature programming language like C++, VB or ..you guessed it, Java. So in this article I've decided to give a brief introduction on how to use Java and ASP. In my next article, I plan on showcasing the true power of using ASP with Java by grabbing info from another website. With Java's hardcore networking capabilities, it'll be a snap. And when we're done we'll grab live stock info right from Nasdaq's website!
First, Let's start with what you'll need:
- Personal Web Server or IIS
- Microsoft's Java SDK 3.2 or higher
- Microsoft's latest Java Virtual Machine
Grab the latest of these from http://microsoft.com/java. Using these we can write the code right in notepad and compile the classes right from the command line. No wussy WSYWIG here.
Let's start coding! Open up notepad or any other text editor and dig in. Let's start with a "Hello Geek" example to get us started. Here's the Java:
|
Ok, so far pretty simple? Now save your code into the
same directory that jvc.exe exists (This should be in the Bin
Directory under the SDK directory). Name the file hello.java.
Now go the the command line and change directories to the same
directory. At the prompt type
jvc hello.java
|
Note that the .java file must
be the same name as the public class name (case sensitive) or
you'll get an compile error.
In your bin directory now should be a file named hello.class.
This is the compiled Java class file. Copy this into C:\Winnt\Java\TrustLib.
Now we can access this class file from the ASP using the following
code:
<%
|
This wraps up the first part of the article. You'll see that writing a Java object and accessing it using ASP is really simple. And it's quick too! In the next article we'll really dig in and build a Java object that retrieves stock quotes right from the source! Pretty neat, eh? (Read the next article, Using Java & ASP to Grab Stock Quotes!)
Attachments:
hello.java in text formathello.asp in text format
Related Links:
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




