This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi my professional Friends I have a jsp and a servlet(IDE: Oracle9i Jdeveloper). **senario: 1-submiting a request from jsp to servlet, using the following address: servlet/Pkg_Servlets.Srv_Srv1 2-dispatching the recieved request to the very same jsp again: RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/untitled1.jsp"); dispatcher.forward(req, res); 3-Again,repeating the stage number 1 **Problem: For the first time the JSP finds Servlet but for the second time after no-3 I get ERROR since there is an extra "servlet" attached to the servlet's url like this: Resource /Workspace1-Project1-context-root/servlet/servlet/Pkg_Servlets.Srv_Srv1 not found on this server Thank you for any hint and advice. Best Regards, Pourang [ December 17, 2002: Message edited by: Pourang Emami ]
Indeed. This is a big issue with me and makes the software dictate the layout of the web pages to a degree. I dont like that much.
This is a problem with resolution of names between servlets and JSPs. You probably used relative linking from your JSP. When a servlet forwards to a JSP it does NOT change the address in address bar. More importantly, the web page has a new root. if web page is here http://serverPages/myDirectory/aJSP.jsp and servlet is here http://servlet/aServlet all relative links in the jsp page will be relative to the servlets location that forwarded you to that page. so if your relative link before resolved like this href="aJSP.jsp" http://serverPages/myDirectory/aJSP.jsp it will now resolve like this http://servlet/aJSP.sjp because its now in the servlets context. (which is now a bad link) Easiest solution is to just make the servlet and the jsp in the same directory When servlets forward to other directories, they make all relative links on the target page relative to that servlet's location.
I map my servlets to *.servletName so they will exist in all directories. Then I reach them by href="1.servletName". that way the context remains the same as the JSP. so when I forward back to that same jsp it works ok. Still their is a problem if you try to forward to a different directory than the servlet was addressed from. Dont know a good way around this.
Joined: Sep 21, 2002
Dear CL Although still some how confused, but thank you so much for your detailed profesSional reply. Seems like a BIG BUG in an Enterprise Solution(J2EE). See u around in the saloon. Regards, Pourang