包括一些返回 401 的页面
我在某些服务器上部署了一些网页,
会显示: http://myhost/some_secured_file.html
当我访问此网页时, 在浏览器中打开文件时,它会返回 401,要求我授权自己。
问题是我试图使用 c:import 标记将此页面包含在某些 JSP 页面中。
应用程序服务器返回:
javax.servlet.jsp.JspException: Problem accessing the absolute URL "http://myhost/some_secured_file.html". java
.io.IOException: Server returned HTTP response code: 401 for URL: http://myhost/some_secured_file.html
我如何完成包含!?
I've some web page deployed at some server say:
http://myhost/some_secured_file.html
when I access this file within a browser it returns 401 asking me to authorize myself.
The problem is that I am trying to include this page inside some JSP page using the c:import tag.
The app server returns :
javax.servlet.jsp.JspException: Problem accessing the absolute URL "http://myhost/some_secured_file.html". java
.io.IOException: Server returned HTTP response code: 401 for URL: http://myhost/some_secured_file.html
How I can accomplish the include!?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑通过另一个 jsp 页面或 servlet 代理请求。然后让代理执行身份验证请求,例如使用 Apache HTTPClient,并让写入页面的响应内容。然后您只需在 jsp 页面上导入代理的 url 即可。
好吧,请考虑以下伪代码作为说明:
此 servlet 的作用是为您获取受保护的页面。您需要将此 servlet 连接到您的 Web 描述符中。这是将例如
/proxy.jsp
请求映射到它所必需的。然后您可以在 jsp 页面中执行类似
的操作。Consider proxying the request through another jsp page or servlet. Then you let the proxy perform an authenticating request, e.g., using Apache HTTPClient, and have the contents of that response written to the page. Then you can simply import the url of your proxy on your jsp page.
Alright, consider the following pseudo code as clarification:
What this servlet does is fetch the secured page for you. You need to hook this servlet up in your web descriptor. This is necessary to map e.g.,
/proxy.jsp
request to it. What you then can do in your jsp page is something like<c:import value="proxy.jsp"/>
.