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 R运行没有名称为"species"的插槽对于此对象类"SDMmodelCV"
  • ¥20 基于决策树的数字信号处理,2ask 2psk 2fsk的代码,检查下报错的原因
  • ¥20 python作业求过程
  • ¥15 wincc已组态的变量过多
  • ¥60 如图:直线与椭圆X轴平行,求直线与椭圆任意一点的相切坐标计算公式
  • ¥50 如何用python使用opencv里的cv::cudacodec::VideoWriter函数对视频进行GPU硬编码
  • ¥100 c#solidworks 二次开发 工程图自动标边线法兰 等折弯尺寸怎么标
  • ¥15 halcon DrawRegion 提示错误
  • ¥15 FastAPI Uvicorn启动显示404
  • ¥15 centos7.9脚本,怎么排除特定的访问记录