Need a way to pass object to another application

Hello Everyone,

I need to pass an object from one application to another. I wanted to do that using request.setAttribute(Object) but this works only on RequestDispatcher.forward(URL) method and can be used only within the application you are currently in. It does not work for absolute URLs therefore I cannot go to another application. I also tried response.sendRedirect(URL) but then request object is lost when redirected to another application.

Any help will be greatly appreciated,

Thanks in advance,

Y.M.

[544 byte] By [yurkom] at [2007-9-27 19:42:44]
# 1

if your two application servers are on the same box, then you can get the RequestDispatcher object from another ServletContext and then use the request.setAttribute() call.

ServletContext newContext = getServletContext().getContext(webApp);

if( newContext == null )

throw new IllegalArgumentException("Invalid webApp '"+webApp+"' does not exist.");

request.setAttribute("myobject", objToPass) ;

RequestDispatcher dispatcher = newContext.getRequestDispatcher(urlToGoTo) ;

dispatcher.forward(request, response);

yoda23 at 2007-7-6 23:01:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
btw, don't cross post. its annoying.
yoda23 at 2007-7-6 23:01:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Hi yurkom,

Take a look at Tangosol's <a href="http://www.tangosol.com/coherence.jsp">Coherence</a> clustered caching/objectstore product. It allows any JVM on the network to have access to a store of data. That data can be "replicated" or "distributed" across those JVMs. Check out the product announcement on The ServerSide (http://www.theserverside.com).

Later,

Rob Misek

http://www.tangosol.com

rmisek1 at 2007-7-6 23:01:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

> if your two application servers are on the same box,

> then you can get the RequestDispatcher object from

> another ServletContext and then use the

> request.setAttribute() call.

> > ServletContext newContext =

> getServletContext().getContext(webApp);

>

> if( newContext == null )

> throw new IllegalArgumentException("Invalid webApp

> p '"+webApp+"' does not exist.");

>

> request.setAttribute("myobject", objToPass) ;

> RequestDispatcher dispatcher =

> newContext.getRequestDispatcher(urlToGoTo) ;

>

> dispatcher.forward(request, response);

>

>

Unfortunately those apps are on different servers ...

yurkom at 2007-7-6 23:01:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...