6.2 HTTP Request, Session, and Principal

When you use the servlet-based report server (Repository Servlet) you can access the http request and session objects via script. Use the parameter array to access the HttpServiceRequest/HttpServiceResponse object, which are wrappers, respectively, for the HttpServletRequest/HttpServletResponse objects.

Note: Although you can set HttpSession properties directly, the it is best to set them on the SRPrincipal. SRPrincipal can be accessed universally within the script of a report or a VPM trigger.

For example, the script below handles the http session attributes and request parameters via the HttpServiceRequest object.

//accessing the service request object

var serReq = parameter['__service_request__'];

 

// getting session attributes

var sessAttr = serReq.getAttribute('attribute_name');

 

// setting session attributes

serReq.setAttribute('attribute_name', value_object);

 

// setting HTTP request parameter

serReq.setParameter('param_name', 'param_value');

// getting the SRPrincipal object

var p = parameter['__principal__'];

 

// getting a standard SRPrincipal property, user locale:

var locale = p.getLocale();

 

// getting a custom principal property

var prop = p.getProperty("myprop");

To get a direct handle on the HttpServletRequest object, use the following syntax:

var httpReq = serReq.getRequest();

Use the following simplified syntax to acquire the current username:

var userName = parameter['_USER_'];

See Also

Changing the Server Type, in Administration Reference, to configure servlet.

Accessing SRPrincipal via Login Listener, in Integration, for the recommended approach.

RepletParameters Object, for a complete list of special parameters.

<< 6.1 Accessing Report/Request Parameters © 1996-2013 InetSoft Technology Corporation (v11.5) 6.3 Interactive Forms >>