+

Search Tips   |   Advanced Search

Writing filters for the web application bridge


We can use filters to manipulate the request content going from the IBM WebSphere Portal page to the backend site. We can also use filters to manipulate the response coming from the backend site to the portal page. These filters are basically servlet filters.

To write filters for the web application bridge:

Contact IBM Support for details about how to write filters.

  1. Create a file using the following sample code to insert a sample header into a request going from the portal to the backend site:
    public class HeaderInsertFilter implements javax.servlet.Filter{
    
     public void init(FilterConfig arg0) throws ServletException {// No-op }
    
     public void destroy() {// No-op}
    
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws         IOException, ServletException {
      ReverseProxyRequest proxyRequest=(ReverseProxyRequest)request;
      HttpClientArguments args=proxyRequest.getHttpClientArguments();
      HttpHeaders headers=args.getHeaders();
    
      /* Add a header */
      headers.addHeaderValue("myHeader",myHeaderValue);
    
      /* Refresh the headers (just to be safe */
      args.setHeaders(headers);
    
      /* Continue the chain */
      chain.doFilter(request,response);
     }
    
    }
    

  2. To engage the filter:

    1. Create a filter component with at least one class implementing the javax.servlet.Filter interface.

    2. Compile the class against the servlet (runtime.jar in the wp_profile/installedApps/cell-name/wp.vwat.servlet.ear.ear/wp.vwat.servlet.war/WEB-INF/lib directory) and engine JAR files (in the wp.vwat.engine.jar in wps/shared/app directory) and all portal/WAS jar and compressed files.

      Consider using the RAD Portal project because it already has the correct build paths for IBM WebSphere Portal and IBM WAS.

    3. Build a JAR with the compiled class files.

    4. Place the JAR file in the same location as the runtime.jar file.

    5. Restart the WebSphere_Portal server.


Parent: The web application bridge