Chapter 8 Using Java Servlets and Java for XML Parsing



Note:  These technologies are currently unsupported by Netmar. This page was created as a convenience for Netmar customers, courtesy of Steve Barr.  For support, please see the available public support resources available through http://www.javasoft.com/, http://www.apache.org, and http://java.apache.org/jserv.

Account Configuration

It is recommended for ease of development that you set up a similar configuration on your own computers so you can do the bulk of your development and testing locally.  You can then FTP the files up to your account for final testing and production deployment.

Determine Netmar's configuration:

  • See what web server and servlet engine Netmar is running: http://www.netcraft.com/whats/?host=netmar.com.  It is currently Apache with the JServ servlet engine.  You can get these for various platforms from http://www.apache.org.
  • See what version of Java, Java Servlet SDK and Java API for XML parsing Netmar is running.  Currently you can see by issuing the following command at the shell prompt: ls /opt/java (As of April 22nd, 2000, Netmar is running Java 1.1.8, Java Servlet SDK 2.0, and Java API for XML Parsing 1.0).  You can download Java packages for various platforms from http://www.javasoft.com.
Activate Servlets in your account:
  • Click here to request that a zone be created in your account.  For this document, we will assume your account name is account, your zone's servlet repository is located in the ~account/servlets directory (/users/a/account/servlets), a servlet is launched by http://www.yourdomain.com/js.account/servletname
  • Set your servlets directory and any servlets to be readable and executable by all: chmod ugo+rx filename
If you wish to compile programs in your account, you should add java to your path by set PATH=(/opt/java $PATH) or by adding it to your set path statement in your .cshrc file.  You will also want to add environment variables to your .cshrc file:
# for Java Servlets and Java API for XML Parsing
setenv JAVA /opt/java
setenv JAVA_HOME $JAVA/jdk1.1.8
setenv CLASSPATH .:$JAVA/jdk1.1.8/lib/classes.zip:$JAVA/jaxp1.0/jaxp.jar:$JAVA/jaxp1.0/parser.jar:$JAVA/JSDK2.0/lib/jsdk.jar

At the prompt type:

  • source .cshrc to activate the changes.
  • echo $CLASSPATH and echo $PATH to see if the changes in your .cshrc took effect.
  • which java to see if you are finding the correct java file.

Testing Your Configuration

Once you have your account configured, you can FTP a servlet class file from your copy of the servlet development kit into your zone and see if you can launch it from your browser: http://www.yourdomain.com/js.account/servletname .  You can FTP a servlet or XML Java source file to your account and compile it by javac file.java.  You can run a non-servlet Java class by java file .  If you get a "core dump" message, try changing the line limit coredumpsize 0 to limit coredumpsize 200 and then source your .cshrc file.

Resources

Start with these links to learn more:
Apache: http://www.apache.org, http://java.apache.org/
Java: http://www.javasoft.com, http://web2.java.sun.com/docs/books/tutorial/
XML: http://www.xml.org