相关疑难解决方法(0)

Servlet转发响应呼叫者/上一页

我试图将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)

和其他选项,不能使它工作.

我究竟做错了什么?

java servlets java-ee servlet-3.0

6
推荐指数
1
解决办法
4万
查看次数

OpenId + JSF将用户重定向到他登录的页面?

我正在使用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)

现在,当应用程序启动并且用户想要访问时

HTTP://www.somehost:8080/MyApp的/核心/ abc.xhtml

web.xml的帮助下我现在可以向用户显示一个登录页面我在这里用openid登录如谷歌,雅虎现在我的问题是我怎么能告诉openid我的返回网址

HTTP://www.somehost:8080/MyApp的/核心/ abc.xhtml

或者如果用户来自

HTTP://www.somehost:8080/MyApp的/核心/ xyz.xhtml

此网址成功登录后,用户将转到此页面.

java openid jsf web.xml

6
推荐指数
1
解决办法
1245
查看次数

如何获取客户端的URL

我正在向Display.jspTrialShow.jsp页面发送请求,但每当我${pageContext.request.requestURL}在TrialShow JSP页面中调用时,我都会将其http://localhost:8081/newjsp1/TrialShow.jsp作为输出.如何http://localhost:8081/newjsp1/Display.jsp在TrialShow JSP页面中显示 ?

java jsp jstl

3
推荐指数
2
解决办法
9249
查看次数

标签 统计

java ×3

java-ee ×1

jsf ×1

jsp ×1

jstl ×1

openid ×1

servlet-3.0 ×1

servlets ×1

web.xml ×1