Suppose number of servlets/jsps from various web applications want to access shared data, what is the mechanism to achieve the same?

Questions by hmashruf   answers by hmashruf

Showing Answers 1 - 14 of 14 Answers

Vikash

  • Apr 11th, 2006
 

Hi,

For sharing resources among different servler you needs to put data in ServletContext.

Vikash

  Was this answer useful?  Yes

Guest

  • Apr 22nd, 2006
 

the only 1 servlet context for entire application, all the part of web application share it . Container makes servlet context when a web application is deployed and makes it available to all each servlet n Jsp in web application.

this servlet contet is one per app but only if application is in a single jvm.. in distr.environ. you will have one servlet context per JVM

riteshyadav14@rediffmail.com

  Was this answer useful?  Yes

antony praveen

  • Apr 28th, 2006
 

Hi,

      The above comments are not the solution for this question... The question is "servlets/jsps from various web applications want to access shared data".

Servlets/jsps from various web applications... If you put any thing in servlet context. It will be available for all the servlets/jsp's which is in the same web application. But In this case Consider Servlet1 is running in one application and Servlet2 is running in another application. Here how can we share the data?. ServletContext won't work here ok.

  Was this answer useful?  Yes

Hi Antony,

To me the solution, wherein the servlets from different web-applications with an assumption the both web-apps running under same servlet container, is to facilate communication mechanism with custom solution. Either thru. with database or Servlet1 calling Servlet2.

-ashruf

  Was this answer useful?  Yes

Rajarshi

  • May 13th, 2006
 

If you want several servlets , each running as individual and independent of each other and want to share some data, the put the data in the common, shared area of the web appplication containier. In this way the shared data can be accessed by all servlets/jsp's etc.

However the issue is if every one wants to write in that shared data , then its difficult. You have to make the data read only, then there will be no issue.

  Was this answer useful?  Yes

C.R.Venkatesh

  • May 15th, 2006
 

Yes, it's very true that the data in servlet context *cannot* be shared across applications (even if all these applications run in the same container). To answer you question, the best and obvious solution would be to bind the data (that you want to share) in JNDI tree. Hope it answers your question. Revert back if you find any other alternative.

  Was this answer useful?  Yes

vaibhav

  • May 15th, 2006
 

hi

for doing this we have to define all mapping in deployement descripter.

you can do this using web.xml file  or in the configuration of the application server or web server.

thanks.

please give comment if any............!

  Was this answer useful?  Yes

If you want several servlets , each running as individual and independent of each other and want to share some data, the put the data in the common, shared area of the web appplication containier. In this way the shared data can be accessed by all servlets/jsp's etc
For sharing resources among different servlet you need  to put data in ServletContext.
if SOne if running in weblogic and STwo in Tomcat
the in SOne service method use response.sendRedirect("http://localhost:8080/app2/url/of/stwo")

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions