0

我想将 Java(POJO 类)对象发送到安装在不同或相同 tomcat 上的其他应用程序。

我在同一个tomcat上使用and和我的两个应用程序时尝试过request.setAttribute("abc",javaObj)但获得了null价值。我正在使用重定向 jsp。request.getAttribue("abc")scope="application"

4

2 回答 2

1

如果你想在同一个 tomcat 下的两个应用程序之间共享一个变量,那么你需要使用 setAttribute 方法在 servletcontext 中设置它。

要将 POJO 发送到不同的 tomcat 或 JVM,您可以使用 RMI 或 HTTP。

于 2013-05-14T05:28:09.720 回答
0

使用 RequestDispatcher 和 setAttribute

RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("your url");
MyPojoObject m=new MyPojoObject();
request.setAttribute("abc", m);
dispatcher.forward(request, response);

取回

MyPojoObject mo=(MyPojoObject)request.getAttribute("abc");
于 2013-05-14T05:46:05.003 回答