将请求分派到 WebLogic 11g 上的 JspServlet 的无限循环
我有以下配置:
ServletA(在我的例子中是 Apache CXFserlet - 但这并不重要),它匹配所有请求 - /*。 ServletB,它正在分派到一个命名的 servlet - 如果可用则为“jsp”,否则为“JspServlet”。
ServletA 配置为将所有 JSP 请求转发到 ServletB。这工作完美。
另一方面,如果应用程序在 Tomcat 上运行,则 ServletB 正在转发到“org.apache.jasper.servlet.JSPServlet”,如果我使用 Oracle Weblogic,则转发到“weblogic.servlet.JSPServlet” 。
Tomcat 上一切都运行完美。
在Weblogic上,我遇到以下问题: ServletA 正在转发到 ServletB,它转发到 weblogic.servlet.JSPServlet
。 JSPServlet 应该为 JSP 提供服务,但事实并非如此。相反,我陷入了无限循环(ServletA -> ServletB -> JSPServlet -> ServletA -> ...)
有谁知道里面发生了什么weblogic.servlet.JSPServlet
,并且知道如何让 Weblogic 为我的 JSP 提供服务吗?欢迎所有想法和建议...我已经在这个问题上投入了太多时间但没有成功。
注:
- 在 Weblogic 10.3.5 上测试;
- 如果 ServletB 转发到虚拟 servlet,则不会发生循环;
- 转发是通过使用 RequestDispatcher 完成的,通过调用 getNamedDispatcher("jsp")(对于 Tomcat)或 getNamedDispatcher("JspServlet")(对于 WebLogic)来检索。
I have the following configuration:
ServletA (in my case Apache CXFserlet - but this is not important), which is matching all requests - /*.
ServletB, which is doing dispatch to a named servlet - "jsp" if it is available or "JspServlet" otherwise.
ServletA is configured so that it is forwarding to ServletB all JSP requests. This is working perfect.
On the other hand ServletB is doing forward to "org.apache.jasper.servlet.JSPServlet" if the application is running on Tomcat or to "weblogic.servlet.JSPServlet" if I'm using Oracle Weblogic.
Everything is working perfect on Tomcat.
On Weblogic, I have the following problem:
ServletA is forwarding to ServletB it forwards to weblogic.servlet.JSPServlet
. The JSPServlet is supposed to serve the JSP but it does not. Instead of this I get to an endless loop (ServletA -> ServletB -> JSPServlet -> ServletA -> ...)
Does anyone have an idea what is going on inside weblogic.servlet.JSPServlet
, and have any idea how I can get Weblogic to serve my JSP? All ideas and suggestions are welcome... I have already invested too much time in this problem without any success.
NOTES:
- Tested on Weblogic 10.3.5;
- If ServletB forwards to dummy servlet no loop occurs;
- Forwarding is done by using RequestDispatcher, retrieved by calling getNamedDispatcher("jsp") for Tomcat or getNamedDispatcher("JspServlet") for WebLogic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是 Weblogic 在 URL 映射方面严格执行的新 Servlet 2.5 规范。
/
(正斜杠)字符的 servlet 路径字符串指示应用程序的默认 servlet。 Servlet 路径解析为请求 URI 减去上下文路径;在这种情况下,路径解析为 null。*
(星号)开头的字符串指定扩展映射。这些更改引入了以下 HttpServletRequest 方法的行为更改:
为了更好地说明行为更改,请考虑解析为 ServletA 的请求
/abc/def.html
:/< /code> 映射到 ServletA,然后是
servletPath="abc/def.html"
和pathInfo=null
。/*
映射到 ServletA,则为servletPath=""
和pathInfo="abc/def.html"
。要确保返回的路径信息非空,请将所有出现的
/
(正斜杠)servlet 映射字符串替换为/*
。I think its the new Servlet 2.5 specs which Weblogic strictly enforces when it comes to URL mapping.
/
(forward slash) character indicates the default servlet of the application. The servlet path resolves to the request URI minus the context path; in this case, the path resolves to null.*
(asterisk) specifies an extension mapping.These changes introduce a change in behavior with the following HttpServletRequest methods:
To better illustrate the change in behavior, consider the request
/abc/def.html
that resolves to ServletA:/
maps to ServletA, thenservletPath="abc/def.html"
andpathInfo=null
./*
maps to ServletA, thenservletPath=""
andpathInfo="abc/def.html"
.To ensure that the path info returned is non-null, replace all occurrences of the
/
(forward slash) servlet mapping string with/*
.