Communicator e3000 MPE/iX Release 6.5 Express 2 (Software Release C.65.02) (30216-90322)

44 Chapter3
Technical Articles
Java Servlets for MPE/iX
Servlets are compiled using the Java compiler, javac. The path to the javac binary can be
fully qualified or the PATH variable can be modified to include it. PATH can be set at the
command line or in a profile file.
shell/iX>/usr/local/java/latest/bin/javac HelloWorld.java
or
shell/iX>export PATH=/usr/local/java/latest/bin:$PATH
shell/iX>javac HelloWorld.java
If you are planning to compile multiple servlets, you may want to set the PATH and
CLASSPATH variables in the .profile file for MGR.APACHE or in the system-wide
/etc/profile.local file. To create a new .profile file with these variables for
MGR.APACHE:
:HELLO MGR.APACHE
:XEQ SH.HPBIN.SYS -L
shell/iX>echo export PATH=/usr/local/java/latest/bin:\$PATH > .profile
shell/iX>echo export CLASSPATH=/APACHE/PUB/lib/jsdk.jar:\$CLASSPATH >>
.profile
shell/iX>. ./.profile
Running Java Servlets
The sample configuration files are set up to execute servlets from the
/APACHE/PUB/servlets directory for standard Apache and from
/APACHE/SECURE/servlets for WebWise. This is where your servlet .class files must
reside. This directory is a servlet repository in the " root" zone and is configured in the
root.properties file:
repositories=/APACHE/SECURE/servlets
To run the servlet HelloWorld from the servlets repository, enter its URL in your web
browser:
http://yourhost.com:port/servlets/HelloWorld
or
http://yourhost.com:port/servlet/HelloWorld
"HelloWorld" is the name of the servlet to run and "servlets" and “servlet” are the mount
points for the "root" zone. Zone mount points are specified in the jserv.conf file using the
ApJServMount directive. Here are the ApJServMount values set in the jserv.conf.sample
file:
ApJServMount /servlets /root
ApJServMount /servlet /root
Mounting maps a URL to a zone. With the above mounts , requests to a URL starting with
/servlets or /servlet will be handled by the servlets in the zone "root."
Servlets can be passed input in a manner similar to CGI. To run the servlet "MyServlet"
with an address input value, the URL would be,
http://yourhost.com:port/servlets/MyServlet?address=foo@bar.com