Saturday, August 29, 2009

Oracle's http server : compile and host a servlet

1. First of all I checked whether Apache is up:
[root@mylinux32box ohs]# export ORACLE_HOME=/home/oracle/oracle/OracleAS
[root@mylinux32box ohs]# cd $ORACLE_HOME/opmn/bin
[[root@mylinux32box bin]# ./opmnctl status
Processes in Instance: IAS-1
-------------------+--------------------+---------+---------
ias-component | process-type | pid | status
-------------------+--------------------+---------+---------
HTTP_Server | HTTP_Server | 6665 | Alive
2.Now I wanted to compile a servlet and for that
Environment variable CLASS_PATH should contain the path to javaws.jar (under
the jre/lib directory) and servlet.jar
Environment variable FILE_SEPARATOR should be set: ";" on win32 and ":" on
unix).
Environment variable TMPDIR should point to the tmp directory
Environment variable SDK_HOME should point to the SDK directory.
3.Then I went to http://tomcat.apache.org/download-55.cgi and downloaded "apache-tomcat-5.5.28.tar.gz" -- the CORE VERSION.
Then after unzipping :
[root@mylinux32box SERVLET_LIB]# ll
total 15036
drwxr-xr-x 11 root root 4096 Aug 28 13:39 apache-tomcat-5.5.28
-rw-r--r-- 1 root root 15370240 Aug 28 13:38 apache-tomcat-5.5.28.tar
[root@mylinux32box SERVLET_LIB]# cd apache-tomcat-5.5.28
[root@mylinux32box apache-tomcat-5.5.28]# ll
total 100
drwxr-xr-x 3 root root 4096 Aug 28 13:39 bin
drwxr-xr-x 6 root root 4096 Jul 24 12:34 common
drwxr-xr-x 3 root root 4096 Jul 24 12:36 conf
-rw-r--r-- 1 root root 40487 Jul 24 12:36 LICENSE
drwxr-xr-x 2 root root 4096 Jul 24 12:34 logs
-rw-r--r-- 1 root root 759 Jul 24 12:36 NOTICE
-rw-r--r-- 1 root root 9082 Jul 24 12:34 RELEASE-NOTES
-rw-r--r-- 1 root root 8042 Jul 24 12:36 RUNNING.txt
drwxr-xr-x 5 root root 4096 Jul 24 12:34 server
drwxr-xr-x 4 root root 4096 Jul 24 12:34 shared
drwxr-xr-x 2 root root 4096 Aug 28 13:39 temp
drwxr-xr-x 8 root root 4096 Jul 24 12:34 webapps
drwxr-xr-x 2 root root 4096 Jul 24 12:34 work
[root@mylinux32box apache-tomcat-5.5.28]#
4. Under : /home/oracle/oracle/OracleAS/SERVLET_LIB/apache-tomcat-5.5.28/common/lib
got servlets-api.jar files and for making life easier copied them under SERVLET_LIB
For setting up the environment correctly created the following env_java.sh file:
[root@mylinux32box ~]# cat env_java.sh
export JAVA_BIN=/home/oracle/oracle/OracleAS/jdk/bin
export PATH=$PATH:$JAVA_BIN
export CLASSPATH=/home/oracle/oracle/OracleAS/jdk/jre/lib/javaws.jar
export CLASSPATH=$CLASSPATH:/home/oracle/oracle/OracleAS/jdk/lib/*.jar
export CLASSPATH=$CLASSPATH:/home/oracle/oracle/OracleAS/SERVLET_LIB/servlet-api.jar
5.After importing the environment went to /home/oracle/oracle/OracleAS/jdk/sample/jnlp/webpad/src/servlet
and compiled the servlet program.


Now Put a servlet file in " /root/tomcat/webapps/servlets-examples/WEB-INF/classes" [ for me it is MyServlet.java]

Compile it

Go to "/root/tomcat/webapps/servlets-examples/WEB-INF" add


MyServlet
MyServlet



MyServlet
/servlet/MyServlet


In web.xml

Try url http://myurl.com:8080/servlets-examples/servlet/MyServlet

No comments:

Post a Comment