简体   繁体   English

通过jsp从另一个网页调用网页

[英]Calling a webpage from another webpage via jsp

I am trying to figure out how to do the following. 我正在尝试找出以下方法。

I have webpage at a certian location called www.hello.com/logout.jsp 我在certian位置有一个网页www.hello.com/logout.jsp

What I am trying to do with logout.jsp is delete all the cookies that were stored when initially logging in. The problem is that there exists a cookie for a website with a different domain that is stored when logging in. The one way I can delete that cookie is through the logout link for that website eg www.hello2.com/logout.jsp 我要使用logout.jsp是删除最初登录时存储的所有cookie。问题是,存在用于登录时存储了其他域的网站的cookie。一种方法是通过该网站的注销链接删除该cookie,例如www.hello2.com/logout.jsp

Is there anyway I can call www.hello2.com/logout.jsp from www.hello.com/logout.jsp ? 反正我有可以打电话www.hello2.com/logout.jspwww.hello.com/logout.jsp I am trying to just make a call for www.hello2.com/logout.jsp from www.hello.com/logout.jsp and then redirect the user to another page on www.hello.com 我正在尝试从www.hello.com/logout.jsp拨打www.hello2.com/logout.jsp的电话,然后将用户重定向到www.hello.com上的另一个页面

Thanks in advance :D 提前致谢

If I understand correctly, you are trying to do an HTTP POST( or GET ) to www.hello2.com/logout.jsp while processing HTTP request to your web application's logout.jsp . 如果我理解正确,那么您在处理对Web应用程序logout.jsp HTTP请求时,尝试对www.hello2.com/logout.jsp进行HTTP POST(或GET)。

You should really consider coding your logic in Servlets and using JSPs only to present data, but in the meantime you can create a scriptlet inside your logout.jsp and do a call to another web page in there ( just don't code the whole thing in JSP, only make a call to a static method ). 您应该真正考虑在Servlet中编码逻辑并仅使用JSP来呈现数据,但是与此同时,您可以在logout.jsp内创建一个scriptlet并在其中调用另一个网页(只是不要对整个网页进行编码)在JSP中,仅调用静态方法)。

In that static method you can use HttpClient to do whatever HTTP request you need from www.hello2.com. 在这种静态方法中,您可以使用HttpClient来执行您需要从www.hello2.com发送的任何HTTP请求。

Here are additions to your logout.jsp 这是您logout.jsp的补充

<%@ page import="my.package.Hello2Call" %>

<%
    Hello2Call.postLogoutRequest( );
%>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM