This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Murach's MySQL and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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

how to share data between servlet in different webapplication

 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
servlet A receives a request that it forward to servlet B
within another web application in the same web container
servlet A need to share data with servlet B and data must be
not visible to other servlets in A's web application
in which object can the data that A shares with B be stored

1. http session
2.servletconfig
3.servletcontext
4httpservletrequest
5httpservletresponse

hi ranchers
please tell the answer
according to me answer must be 4 or 5
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


servlet A receives a request that it forward to servlet B
within another web application in the same web container



It may not be that simple. You cannot forward outside your 'context'. You could ofcourse, always, redirect.


servlet A need to share data with servlet B



Date could be stored in
1. db
2. a serialized object

You cannot store it in the standard servlet api objects, not even the context object.

ram.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ramprasad madathil:
Data could be stored in
1. db
2. a serialized object



In addition you can redirect it from one to another in the URL, if its like parameter string.
 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

which is the most suitable answer
please tell
 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we can redirect it by httpservletrequest object
so can it be appropriate
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rehans oberoi:
which is the most suitable answer



It depends, what kind of data you want to share.

If simple strings then you can use URL approach. Otherwise, db, serialized objects, ldap, web services, etc are other means of sharing data.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This thread might be helpful.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel one option will be to use HttpURLConnection. From the first servlet wecan make a connection to second servlet using this class. Using HttpURLConnection will ensure that the communication is only between two Servlets and helps you two transfer the data without constraints.
 
Ranch Hand
Posts: 153
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, JAVA EE specification does't talk about share the data between two web application context. You can't share data either in Request or Response object. You may have reconsider you design.

Hope that helps.
 
reply
    Bookmark Topic Watch Topic
  • New Topic