简体   繁体   中英

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

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

Is there anyway I can call www.hello2.com/logout.jsp from www.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

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 .

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 ).

In that static method you can use HttpClient to do whatever HTTP request you need from www.hello2.com.

Here are additions to your logout.jsp

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

<%
    Hello2Call.postLogoutRequest( );
%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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