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]

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);
> 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 ...