cancel
Showing results for 
Search instead for 
Did you mean: 

Concept similar to ServletContext available for WD?

Former Member
0 Kudos

Hi,

in standard J2EE web applications there is the ServletContext (als known as the predefined JSP-variable application) which can hold application specific data that can be accessed by any user session as long as the web application is running. In J2EE web apps I frequently use the ServletContext as a shared cache for certain data read from a database.

Now I wonder if there is something similar available for WD java applications.

My understanding is that a controller context within the root component of the WD application does not do the job, because the root component is instantiated on a per session basis.

Is there any concept similar to a ServletContext available for WD applications?

If not is there a best practice how to simulate such a concept?

Regards,

Sven

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Look at WDScopeUtil class. The javadocs are [here|http://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/services/session/api/WDScopeUtil.html].

Regards,

Satyajit

Former Member
0 Kudos

Hi Satyajit,

thanks for the pointer to the WDUtils class. The javadocs says "Users must not rely on objects being available within the scope i.e. a get might fail even after a put with the same key has been done", which does not sound very reliable. Do you have experience using this class?

Regards,

Sven

Answers (2)

Answers (2)

jrgen_bechtle
Participant
0 Kudos

Dear Sven,

I have done some investigation on this topic. Due to the fact that one shouldn't access the HttpRequest in a webdynpro application, consquently one shouldn't access the underlying Servletcontext as well.

In order to store data in memory for usage as e.g. valuehelp content like in a project i am working on there are 2 possibilities:

1) implement a portal service that holds the cache in a private member variable, but provides accessor methods for it.

public class ContextService implements IContextService{

private IServiceContext mm_serviceContext;

private Properties mm_applicationCache;

/**

  • Generic init method of the service. Will be called by the portal runtime.

  • @param serviceContext

*/

public void init(IServiceContext serviceContext){

mm_serviceContext = serviceContext;

CrtClassLoaderRegistry.addClassLoader(this.getKey(), this.getClass().getClassLoader());

}

public Properties getCache(){

return mm_applicationCache;

}

tro call the Service in WD.

====================

IContextService portalservice=(IContextService)WDPortalUtils.getServiceRefrence(IContextService.KEY);

portalservice.getCache();

2) the second solution (which i am not going to implement) is using Entity Beans, that hold the Applicationcontext Information. you would access these with SessionBeans (preferrably stateless) that in turns are used as Webdynpromodells (Command bean approach).

best regards,

Juergen

Former Member
0 Kudos

Hi Sven,

There is no session eventings supported by webdynpro and unlike j2ee webapplication the data is maintained in a particular session only.

Regards,

Sri