Oracle JavaServer Pages Developer's Guide and Reference Release 8.1.7 Part Number A83726-01 |
|
There are special considerations in running OracleJSP in Apache/JServ-based platforms, including Oracle Internet Application Server release 1.0.x, because this is a servlet 2.0 environment. The servlet 2.0 specification lacked support for some significant features that are available in servlet 2.1 and 2.2 environments.
For information about how to configure an Apache/JServ environment for OracleJSP, see the following sections:
(If you use Apache/JServ through an Oracle platform, see the installation and configuration documentation for that platform instead.)
The rest of this section, after summarizing the use of Apache/JServ by the Oracle Internet Application Server, discusses the following Apache-specific considerations:
As of Oracle Internet Application Server release 1.0.0 and release 1.0.1, this product uses Apache/JServ as its servlet environment.
As in any Apache/JServ or other servlet 2.0 environment, there are special considerations relating to servlet and JSP usage when using Oracle Internet Application Server release 1.0.x. These are detailed in the sections that follow.
(The Oracle Internet Application Server includes the Oracle HTTP Server, powered by Apache, as its Web server. Be aware that if you use the Oracle HTTP Server mod_ose
Apache mod to run your JSP application in the Oracle Servlet Engine, you are using the OSE servlet 2.2 environment, not the Internet Application Server Apache/JServ servlet 2.0 environment.)
For a brief overview of the Oracle Internet Application Server and its use of the Oracle HTTP Server, see "Support for OracleJSP in Oracle Environments".
JSP dynamic includes (the jsp:include
action) and forwards (the jsp:forward
action) rely on request dispatcher functionality that is present in servlet 2.1 and 2.2 environments, but not in servlet 2.0 environments.
OracleJSP, however, provides extended functionality to allow dynamic includes and forwards from one JSP page to another JSP page or to a static HTML file in Apache/JServ and other servlet 2.0 environments.
This OracleJSP functionality does not, however, allow dynamic forwards or includes to servlets. (Servlet execution is controlled by the JServ or other servlet container, not the OracleJSP container.)
If you want to include or forward to a servlet, you can create a JSP page that acts as a wrapper for the servlet.
The following example shows a servlet, and a JSP page that acts as a wrapper for that servlet. In an Apache/JServ environment, you can effectively include or forward to the servlet by including or forwarding to the JSP wrapper page.
Presume that you want to include or forward to the following servlet:
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class TestServlet extends HttpServlet { public void init(ServletConfig config) throws ServletException { super.init(config); System.out.println("initialized"); } public void destroy() { System.out.println("destroyed"); } public void service (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<HTML><BODY>"); out.println("TestServlet Testing"); out.println("<H3>The local time is: "+ new java.util.Date()); out.println("</BODY></HTML>"); } }
You can create the following JSP wrapper (wrapper.jsp
) for the preceding servlet:
<%-- wrapper.jsp--wraps TestServlet for JSP include/forward --%> <%@ page isThreadSafe="true" import="TestServlet" %> <%! TestServlet s=null; public void jspInit() { s=new TestServlet(); try { s.init(this.getServletConfig()); } catch (ServletException se) { s=null; } } public void jspDestroy() { s.destroy(); } %> <% s.service(request,response); %>
Including or forwarding to wrapper.jsp
in a servlet 2.0 environment has the same effect as directly including or forwarding to TestServlet
in a servlet 2.1 or 2.2 environment.
The servlet 2.0 specification does not provide the full servlet context framework for application support that is provided in later specifications.
For servlet 2.0 environments, including Apache/JServ, OracleJSP supplies its own application framework using a file, globals.jsa
, that you can use as an application marker.
For more information, see "Distinct Applications and Sessions Through globals.jsa".
To share HTTP session information between JSP pages and servlets in an Apache/JServ environment, you must configure your environment so that oracle.jsp.JspServlet
(the servlet that acts as the front-end of the OracleJSP container) is in the same zone as the servlet or servlets with which you want your JSP pages to share a session. Consult your Apache documentation for more information.
To verify proper zone setup, some browsers allow you to enable a warning for cookies. In an Apache environment, the cookie name includes the zone name.
Additionally, for applications that use a globals.jsa
file, the OracleJSP configuration parameter session_sharing
should be set to true
(the default) for JSP session data to be accessible to servlets. See these sections for related information:
Apache supports directory aliasing by allowing you to create a "virtual directory" through an Alias
command in the httpd.conf
configuration file. This allows Web documents to be placed outside the default doc root directory. (An implicit application is created for the Web server document root and each aliasing root. )
Consider the following sample httpd.conf
entry:
Alias /icons/ "/apache/apache139/icons/"
This command should result in icons
being usable as an alias for the /apache/apache139/icons/
path. In this way, for example, the file /apache/apache139/icons/art.gif
, could be accessed by the following URL:
http://host[:port]/icons/art.gif
Currently, however, this functionality does not work properly for servlets and JSP pages, because the Apache/JServ getRealPath()
method returns an incorrect value when processing a file under an alias directory.
OracleJSP provides an Apache-specific configuration parameter, alias_translation
, that works around this limitation when you set alias_translation=true
(the default setting is false
).
For information about how to set OracleJSP configuration parameters in an Apache/JServ environment, see "Setting OracleJSP Parameters in Apache/JServ".
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|