Class WCspErrorLogger


public class WCspErrorLogger extends WResource
An object which can be rendered in the HTTP protocol.

Usage

Besides the main page, other objects may be rendered as additional resources, for example documents or images. Classes such as WAnchor or WImage can use a resource instead of a URL to provide their contents. Whenever the resource has changed, you should call the setChanged() method. setChanged() will make sure that the browser will use a new version of the resource by generating a new URL, and emits the dataChanged() signal to make those that refer to the resource aware that they should update their references to the new URL.

You can help the browser to start a suitable helper application to handle the resource, or suggest to the user a suitable filename for saving the resource, by setting an appropriate file name using WResource.suggestFileName(String).

To serve resources that you create on the fly, you need to specialize this class and reimplement handleRequest(WebRequest, WebResponse).

Concurrency issues

Because of the nature of the web, a resource may be requested one time or multiple times at the discretion of the browser, and therefore your resource should in general not have any side-effects except for what is needed to render its own contents. Unlike event notifications to a JWt application, resource requests are not serialized, but are handled concurrently. Therefore you are not allowed to access or modify widget state from within the resource, unless you provide your own locking mechanism for it.
See Also:
  • Constructor Details

    • WCspErrorLogger

      public WCspErrorLogger()
      Construct a CSP error logger.
    • WCspErrorLogger

      public WCspErrorLogger(int maxReportSize)
      Construct a CSP error logger with the given maximum report size.
  • Method Details

    • handleRequest

      protected void handleRequest(WebRequest request, WebResponse response) throws IOException
      Description copied from class: WResource
      Handles a request.

      Reimplement this method so that a proper response is generated for the given request. From the request object you can access request parameters and whether the request is a continuation request. In the response object, you should set the mime type and stream the output data.

      Specified by:
      handleRequest in class WResource
      Parameters:
      request - The request information
      response - The response object
      Throws:
      IOException
    • logReport

      protected void logReport(String report)