Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Oracle 9iAS, OC4J question regarding shared servlets/EJB's
We are deploying to the OC4J container. Below applications, we have
two different contexts (LTC and REG).
Applications
+
--------LTC
+
--------REG
We have a servlet that is in the LTC context which we would like to
make a call to a servlet running in the REG context. When we make
that call we receive the message java.lang.NullPointerException. As
far as we know from talking to other people, it should be possible to
do this, however, we are not having any luck in making it work.
Perhaps something needs to be modified in one of the xml files, but
the question is (What!).
An example of this would be nice, but we have not found anything that does this. All the examples out there seem to be calling their EJB Beans and Servlets all from within the same context. We want to get system specific in our breakdowns. Even a nice Hello World example in two different contexts would be nice.
A snapshot of the code that we are using:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.lang.*;
import ClientRegistrySystemInfo;
public class LTC_ControllingServlet2 extends HttpServlet {
public void init(ServletConfig config) throws ServletException
{
super.init(config); } public String getServletInfo()
{
return "LTC2"; } public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
HttpSession session = req.getSession(true); String sStep = req.getParameter("STEP"); PrintWriter out = resp.getWriter(); resp.setContentType("text/html"); RequestDispatcher page = null; ServletContext context = getServletContext(); Enumeration en = context.getInitParameterNames(); while (en.hasMoreElements()) { String name = (String) en.nextElement(); Object value = context.getAttribute(name); } String sPhin = req.getParameter("sPhin"); req.setAttribute("sCarrier","1"); req.setAttribute("sGsas","PC"); req.setAttribute("sPhin",sPhin); RequestDispatcher dispatcher = null; // Call the REG Servlet in the REG context. try { this.getServletConfig().getServletContext().getContext("/REG").getRequestDispatcher("/REG_ControllingServlet?STEP=0").include(req,resp); } catch (Exception e) { out.println(e.getClass().getName() + " " + e.getMessage ()); e.printStackTrace(); } page = this.getServletContext().getRequestDispatcher("/JSP/LTC_ClientDisplayPage.jsp"); page.forward(req, resp);