dongxie3701 2012-10-02 03: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-02 03: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.

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

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵