bankerboy
asked on
Servlets and ServletContext in iPlanet App Server
I am building some servlets and ran into a problem. The problem concerns ServletContext objects and the getContext method.
The idea is pretty simple and I've seen numerous examples on the topic. I have a servlet that is http://localhost/NASApp/Main/MainServlet. I have a second servlet that is /localhost/NASApp/Other/Ot herServlet . I would like the
MainServlet to forward to the OtherServlet. To do this, I am attempting the following in MainServlet:
RequestDispatcher dispatcher;
ServletContext sc = getServletContext();
sc.getContext("/localhost/ NASApp/Oth er");
dispatcher = sc.getRequestDispatcher("/ OtherServl et");
dispatcher.forward(request , response);
This appears to agree with documentation and examples that I have found, but I get a 404 error. I have tried "/Other", "/NASApp/Other", and "/localhost/NASApp/Other" in the getContext call. The OtherServlet works fine when you access it directly via typing the URL into the browser, so I know it works. I am using iPlanet App Server 6.0 and iPlanet WebServer 4.1sp5. I see that the webserver specifies some things that need to be done to get servlets to work, but I'm not using the webserver for the servlets. Rather, I am using iAS to deploy my .ear files for me. I haven't found anything in the iAS docs that point to extra steps that need to be done. Anybody have experience in this area? Your help is greatly appreciated.
The idea is pretty simple and I've seen numerous examples on the topic. I have a servlet that is http://localhost/NASApp/Main/MainServlet. I have a second servlet that is /localhost/NASApp/Other/Ot
MainServlet to forward to the OtherServlet. To do this, I am attempting the following in MainServlet:
RequestDispatcher dispatcher;
ServletContext sc = getServletContext();
sc.getContext("/localhost/
dispatcher = sc.getRequestDispatcher("/
dispatcher.forward(request
This appears to agree with documentation and examples that I have found, but I get a 404 error. I have tried "/Other", "/NASApp/Other", and "/localhost/NASApp/Other" in the getContext call. The OtherServlet works fine when you access it directly via typing the URL into the browser, so I know it works. I am using iPlanet App Server 6.0 and iPlanet WebServer 4.1sp5. I see that the webserver specifies some things that need to be done to get servlets to work, but I'm not using the webserver for the servlets. Rather, I am using iAS to deploy my .ear files for me. I haven't found anything in the iAS docs that point to extra steps that need to be done. Anybody have experience in this area? Your help is greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ServletContext newSC = sc.getContext("blahblahbla
dispatch = newSC.getRequestDispatcher
I was forgetting to assign the getContext call to a new ServletContext. But again, thanks for the reply, since it was a solution that did work.