dongxie3701 2012-10-01 19:26
浏览 73
已采纳

通过重定向在java web服务器和php web服务器之间传递属性

scenario:user visits web container A(Apache Tomcat), A set values in session scope,

HttpServletRequest.getSession().setAttribute(“key”, “value”);

and redirect user to another web container B(a php server).

HttpServletResponse.sendRedirect("path to server B");

Could B get the same values in session scope which's set by A?

HttpServletRequest.getSession().getAttribute(“key”);

according to this question, java servlet application scope redirect

it seems possible, though it might be redirecting to the same container, the httpsession would be in the same VM, or another container in the load-balancing server, httpsession could migrate between these container, thus httpsession would stay still in these two cases.

what if I want to pass attributes between two different server(java and PHP) while redirecting?

wish I do express my thoughts right, any advice would be appreciated, thank you.

  • 写回答

1条回答 默认 最新

  • doubai9014 2012-10-01 19:32
    关注

    If you wish to pass attributes between a Java web server and a PHP web server, you have to add them to the outgoing HTTP request as request parameters (as part of query string, the portion of the HTTP URL after ?).

    The HttpSession information in a Java web server is available on the server side and is connected between two stateless HTTP sessions through JSESSIONID request parameter or cookie (based on if the browser supports cookies). So, any attributes set in the Session of a Java web server will not be available to the PHP web server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部