Gregor Okorn

Greenhorn
+ Follow
since Jun 06, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gregor Okorn

Thank you Karthik for the reply and multiple options. I went with the built-in WebSphere JNDI option that makes available a DistributedMap to all applications deployed on the server. I can set an attribute on this map from one app, then read it from another app. I'm not positive if it's the most efficient solution, but for now it's working. Here are the main steps I took.

From the servlet in the app that sets the attribute on the map:

...
AssignmentSummary[] assignmentsSummaries = new AssignmentSummary[0];
javax.naming.Context jndiContext = new javax.naming.InitialContext();
com.ibm.websphere.cache.DistributedMap dMap = (com.ibm.websphere.cache.DistributedMap)jndiContext.lookup("services/cache/distributedmap");
dMap.put("assignmentsKey_83293298", assignmentsSummaries);
...

From the servlet in the app that reads the attribute from the map:

...
javax.naming.Context jndiContext = new javax.naming.InitialContext();
com.ibm.websphere.cache.DistributedMap dMap = (com.ibm.websphere.cache.DistributedMap)jndiContext.lookup("services/cache/distributedmap");
AssignmentSummary[] assignmentsSummaries = (AssignmentSummary[]) dMap.get("assignmentsKey_83293298");
...


Thanks again for your help,
Gregor



10 years ago
Hello,

I'm trying to figure out the best-practice to allow two servlets that are deployed in two separate contexts to share an array of Java beans.

I'm working with WebSphere, and have a servlet that is to be shared by many different portlets that are defined by many different portlet-apps. Each portlet-app is deployed separately from the other portlet-apps, so they don't share the same session or servlet context like I thought that they might.

The basic idea was to have a portlet 'Pa' set a Java bean array attribute (keyed with 'paJavaBeans') onto its session, and then from that portlet's JSP, call servlet 'S' and have servlet 'S' get the same session attribute (using the key 'paJavaBeans') to process. Found out that the request.getSession() of servlet 'S' is different than the request.getSession() of 'Pa', so the 'paJavaBeans' attribute wasn't shareable via those session objects. I figured that would be too easy, but gave it a try anyway.

My main goal was to avoid having to deploy a copy of servlet 'S' with each webmodule, but instead deploy just one and have all other webmodules access and share it.

If anyone could point me in the right direction to the best-practice that could satisfy this request, I'd appreciate it.

Thanks for your time,
Gregor


10 years ago