Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java

How to get started with server-side Java

Take advantage of the platform-independent, object-oriented power of Netscape's server-side applets. An introduction.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Server-side Java (SSJ), sometimes called servlets or server-side applets, is a powerful hybrid of the Common Gateway Interface (CGI) and lower-level server API programming -- such as NSAPI from Netscape and ISAPI from Microsoft.

This article provides an introduction to and step-by-step instructions for the Netscape implementation of server-side Java, which Netscape calls server-side applets (SSA).

SSAs can act like a CGI script. It receives get and post requests and returns a Web page (usually in the form of HTML), but SSJ is loaded dynamically into the server like NSAPI/ISAPI. This eliminates the start-up delays we've come to expect from CGI. It also allows the SSJ to maintain some of its state between executions, such as keeping an open connection to a database.

SSAs execute in their own sandbox, which provides the security one expects from Java. For example, a crashing applet won't crash the whole server as can happen with NSAPI/ISAPI programming. This added security also allows applets to be uploaded for execution on the server -- just like client-side Java applets are downloaded for execution on the client.

Perhaps the most important aspect of SSAs is that, written in Java, they are inherently platform-independent and object-oriented.

History

A growing number of servers support server-side Java, including the Netscape FastTrack 2.0 and Enterprise 2.0 servers, JavaSoft's Java Web Server (formerly called Jeeves), the World Wide Web Consortium's Jigsaw, WebLogic's T3Server, Oracle's Webserver, and Peak Technologies' ExpressO. Each of these servers uses a different server-side Java API, requiring developers to write different programs for each server they will be using.

Netscape details: Prepare your server

Before authoring your first server-side applet for Netscape's servers, you need to prepare the server. The Enterprise and FastTrack servers are identical in their SSA support.

Start by turning on the server's Java interpreter. This can be done from the Server Manager under "Programs -> Java." Click the Yes button to enable the Java interpreter. The Server Manager will ask you for a "Java applet directory," which is the place to put the SSA support files as well as the location for all SSA class files. It provides a default location. On Unix machines, this is /usr/ns-home/plugins/java/applets. On Windows machines, it is C:\Program&nbspFiles\Netscape\Server\plugins\Java\applets (Note: In this entry field Netscape tends to mix and match its back-slashes and forward-slashes. Don't worry, Netscape treats the two types of slashes in the same way.) Take the default applet directory if possible. If you decide to customize rather than use the default, make sure you choose a directory somewhere under your server root and that you copy all the files from the default location to your custom location. Save and apply your changes, making sure to stop the server and start it again so that the changes take effect.

Time to experiment!

At this point you should be able to experiment with the applets provided by Netscape. Point your browser to http://servername/server-java/FormApplet?abc=xyz&123=789. You should see the "get" data handled and returned in HTML by the Form applet.

If you get a server error, check your server's error log (/usr/ns-home/httpd-hostname/logs/errors or C:\Program&nbspFiles\Netscape\Server\httpd-hostname\logs\errors). If it says it can't start the Java interpreter, a likely cause is that your CLASSPATH is confusing Netscape. Try starting the server in an environment without any CLASSPATH.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (2)
Login
Forgot your account info?

Get current server time on client JSP pageBy Anonymous on May 28, 2009, 5:14 pmIf you want to use show server current time on client page then you have to use Ajax. One good post on the same topic here http://binodsuman.blogspot.com/2009/05/get-current-server-time-on-client-page.html Thanks, Binod...

Reply | Read entire comment

http://dunadelta.dweb.ro/By Anonymous on April 18, 2009, 6:17 amhttp://dunadelta.dweb.ro/

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources