The number of coordinates is huge - in thousands so cant put them in the URL.
I have attempted your second idea. And yes I go to the DB for each request. The problem with the Singleton is, I donno who should start the class. If the HTML servlet starts the Singleton, will the object still be accessible to the image servlet? Thank you, -Vijay -----Original Message----- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 9:42 AM To: Tomcat Users List Subject: RE: Sharing an object between servlets << File: ATT196478.txt >> << File: ATT196479.txt >> Hi, There are many ways you can do this. Here are two examples: 1. Since the HTML servlet embeds the URL of the PNG servlet, why not put the coordinates in the URL? E.g. have the HTML servlet output <img src="myPngServlet?x1=0&x2=1"> and then the PNG servlet does String x1 = request.getParameter("x1"); and so forth. 2. Do you really go to the DB for each request? It may be better (at least for performance, but also addressing this sharing thing) to have a singleton responsible for getting coordinates from the DB. The servlets ask the singleton for the coordinates, which gets them. If the singleton doesn't have them, it goes to the DB and caches the results. So that the second time those coordinates are requested, it's a simple and quick hash lookup (or whatever kind of lookup suits you) to get them. This way you can also pre-cache frequently requested coordinates, and do all sorts of stuff to improve performance... But more importantly it keeps a nicer degree of decoupling between the two servlets. I hope this helps, Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: Vijay Kandy [mailto:[EMAIL PROTECTED]] >Sent: Friday, October 04, 2002 10:28 AM >To: 'Tomcat Users List' >Subject: Sharing an object between servlets > > >Dear All, > >We are building a map tool - to draw maps and show some data on them. Now, >I >have this situation. I have a servlet that gets coordinates from the >database and draws the map on its OutputStream (the content type is set to >png image). There is another servlet (content type is text/html) that >embeds >the URL of the first servlet. This servlet also gets coordinates from the >database, and populates them over the image so I can do some image map or >mouseOver() tricks using javascript. I was wondering if there was a way to >make just one call to the database and share the coordinates between the >servlets. Right now, I will try any thing! > >Thank you, >Vijay > > >-- >To unsubscribe, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
