我试图将servlet响应转发到它来自同一页面(也就是:上一页,或"servlet"调用者).
我通常会执行以下操作将servlet的响应重定向到另一个页面:
request.getRequestDispatcher("MyNewPage").forward(request, response);
Run Code Online (Sandbox Code Playgroud)
但是我试图将"MyNewPage"更改为我见过的其他选项:
request.getRequestDispatcher((String)request.getAttribute("javax.servlet.forward.request_uri")).forward(request, response);
request.getRequestDispatcher(request.getHeader("referer")).forward(request, response);
Run Code Online (Sandbox Code Playgroud)
和其他选项,不能使它工作.
我究竟做错了什么?
我正在使用OpenId4Java和JSF应用程序我已经在我的web.xml中添加了类似这样的安全约束.
<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted</web-resource-name>
<url-pattern>/core/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/user/login.xhtml</form-login-page>
<form-error-page>/user/logout.xhtml</form-error-page>
</form-login-config>
</login-config>
Run Code Online (Sandbox Code Playgroud)
现在,当应用程序启动并且用户想要访问时
在web.xml的帮助下我现在可以向用户显示一个登录页面我在这里用openid登录如谷歌,雅虎现在我的问题是我怎么能告诉openid我的返回网址是
或者如果用户来自
此网址成功登录后,用户将转到此页面.
我正在向Display.jspTrialShow.jsp页面发送请求,但每当我${pageContext.request.requestURL}在TrialShow JSP页面中调用时,我都会将其http://localhost:8081/newjsp1/TrialShow.jsp作为输出.如何http://localhost:8081/newjsp1/Display.jsp在TrialShow JSP页面中显示 ?