Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to share data between servlet in different webapplication

 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • 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
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
This thread might be helpful.
 
Manoj Kumkumath
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • 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.
 
Malatesh Karabisti
Ranch Hand
Posts: 153
Java Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic