• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing variables between 2 wars

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For what I understand the sesssion cannot be shared between 2 wars when they are not deployed on the same EAR. But is there any way to pass one variable from a session to another session?

Is there any way to pass variables between 2 wars (one webapp is invoking a servlet on another webapp)???
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, there are lots of ways.
Which is best depends on what you're doing.

Can you describe the scenario in which you want to pass values from one webapp to another?
 
Amy N. Snow
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Ben,

Well, webapp1 is going to invoke a servlet of webapp2 and webapp 2 is going to perform some database queries. Webapp2 needs to pass some query results to webapp1. Both apps would be on the same app server which will probably be Webshere. Webapp1 is already constructed (its main architecture) so changes on that app should be minimal.
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could always transform the resultset structure to an XML string and write it into the response body when webapp2's servlet returns the response to webapp1's call.

If the interaction between the 2 webapp's is going to be quite extensive, you might even want to consider implementing XMLRPC between the two. It'll take you about half a day to understand the concepts and another half to implement it.
Here's a tutorial which might come in handy.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simplest thing to do is pass these values as querystring or post parameters. As Anirvan mentions, you could respond with XML or some other form of structured data.

The cross context sharing of data is possible between different webapps in the same container but the spec doesn't go into a lot of detail about how it should be implemented. So, the implementation will vary from container to container. You might want to go through your container's documentation to see what it offers in this respect.

Another approach is to read and write to a shared database or (if both web applications are on the same machine, file system).

There are a lot of other technologies offered by Java for interaction between applications. A few are RMI, RPC, SOAP, and JMS. Google is your best friend when researching these.

Hope this helps.
-Ben
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
There are a lot of other technologies offered by Java for interaction between applications. A few are RMI, RPC, SOAP, and JMS. Google is your best friend when researching these.



This was going to be my suggestion. It sounds like you need to look at some kind of middleware, and it better to do this in a professional manner than trying to solve the problem purely on the servlet tier.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would pull the values first from servelet A, and then pass it back to servlet B either as hidden form fields or with querystring. Unless I am a consultant and want to make things complex, I would not do Web Services/ RPC or anything like that.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Jayant Kr", please check your private messages for an important administrative matter.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here we go, I was waiting for someone to post this ... no one did. Sharing Session Data

Although the above is a violation of servlet spec.


Regards
Vyas, Anirudh
reply
    Bookmark Topic Watch Topic
  • New Topic