Subject: How to Set Up OSE to Listen and Respond to HTTP Requests Creation Date: 01-DEC-2000 Purpose: ======== The purpose of this article is to show you the necessary steps to configure Oracle Servlet Engine (OSE) so that it is capable of responding to http requests. Scope & Application: ==================== This article can help all database administrators to create basic web services in their database which will be ready to deploy more complex servlet applications. How to Set Up OSE to Listen and Respond to HTTP Requests: ========================================================= A prerequisite requirement is to have Oracle JServer loaded in the database. Use the dbassist utility if your database is not Java-enabled. Follow the steps below to set up http service in your database. 1. To create http service in your database, connect to your database using the sess_sh utility. For example, $ sess_sh -s sess_iiop://localhost:2481:T817 -u sys/change_on_install 2. When you connect, you can use the scripts bootwebserver.ssh and serverendp.ssh which are found in the $ORACLE_HOME/jis/install directory to create the initial layout for http://webserver service. Type the following commands: (If needed, prefix these commands with the correct path.) $ @bootwebserver.ssh test $ @serverendp.ssh webserver 8000 9000 $ exit Look at the headers of these script files to find the meaning of the script's parameters. These scripts create the new HTTP service, a new servlet domain, and endpoints where this service listens. 3. Create and publish the new demo servlet which is to be accessible through the created service. 1) Use a text editor to create file Hello.java with the following code and save it in a directory named test. --------------------- Code starts here --------------------- package test; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class Hello extends HttpServlet { public void init(ServletConfig config) throws ServletException { super.init(config); } public void doGet(HttpServletRequest request, HttpServletResponse response) th rows ServletException, IOException { response.setContentType("text/html"); PrintWriter out = new PrintWriter (response.getOutputStream()); out.println(""); out.println("Hello"); out.println("

Hello, I am servlet running in OSE

"); out.println(""); out.close(); } } --------------------- Code ends --------------------- 2) Load test/Hello.java file into the database. For this task, use the loadjava utility. For example, $ loadjava -user scott/tiger test/Hello.java 3) You are now ready to publish the Hello servlet. Connect to the database using sess_sh as shown above (or test the created http service and connect via the http protocol as sess_sh -s http://localhost:8000 -u sys/change_on_install). 4) Then type: $ publishservlet -virtualpath examples/test webdomains/contexts/default Hello SCOTT:test.Hello 4. The last thing to do is to start the database Dispatcher process for this web service. To do this, modify init.ora for your database, add the following line, and restart the database. mts_dispatchers = "(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=8000))(DISP=1) (PRE=http://webserver)" 5. You can view the output from the Hello servlet when you use the Web browser and type in the following URL: http://:8000/examples/test For instructions on how to set up mod_ose to communicate with OSE and how to invoke servlets through the standard Web listener, please see [NOTE:126091.1]. References: =========== [NOTE:126091.1] How to setup mod_ose to dispatch requests to configured OSE service. Oracle8i Oracle Servlet Engine User's Guide. Oracle8i Java Tools Reference.