Previous Topic: HttpServletRequestNext Topic: HttpServletResponse


Access Method

The Java version of Web Generation provides two mechanisms for accessing the HttpServletRequest object: user exits or external action blocks.

Accessing through the following set of user exits under the CA Gen install directory hierarchy:

An object named runtimeObject is exposed in the above set of user exits. In a web context, the HttpServletRequest object will be available as the runtimeObject. To utilize this object as an HttpServletRequest object, add the following to the import section of the user exit you are modifying:

import javax.servlet.*;
import javax.servlet.http.*;

Add the following code to any method that uses the object, if:

((runtimeObject != null) && (runtimeObject instanceof HttpServletRequest)) {
  HttpServletRequest request = (HttpServletRequest) runtimeObject;
/**
 *  User-written code should be inserted here
 */
}

Accessing through External Action Blocks:

To use the HttpServletRequest object

  1. Design an External Action Block (EAB).
  2. Use the EAB in the Pstep/Action Block where access to the requested information is desired.
  3. Design the views and attributes that will hold the request information.
  4. Generate the EAB.
  5. Add the following in the EAB method where user code is expected:
    // User-written code should be inserted here
    HttpServletRequest req = (HttpServletRequest)(iefRuntimeParm2.getRequest());
    
  6. Query the desired header as:
    String user = req.getRemoteUser();
    
  7. Set system attributes as:
    globdata.getStateData().setUserId(user);
    
  8. Set attributes in views as:
    w_oa.exservletreq_servletrequest_scheme.set(req.getProtocol());
    
  9. Use the values set in the views of the application logic.

    Note: CA Gen global data (globdata) is available here but CA strongly recommends that users do not use it, as it is subject to change.

  10. Compile the application.