title: Create a cookie using HttpServletRequest?
body: <p>I've created a <code>RenderingPlugin</code>, for use in <code>WebSphere Portal</code>, which is invoked serverside before sending markup to client. The plugin loops through all cookies and if 'test' is not found, I'd like to set that cookie.</p>
  
  <p>I know this is possible with a <code>HttpServletResponse</code> but the <code>RenderingPlugin</code> doesn't have access to that object. It only has a <code>HttpServletRequest</code>.</p>
  
  <p>Is there another way to do this?</p>
  
  <pre><code>public class Request implements com.ibm.workplace.wcm.api.plugin.RenderingPlugin {
  
      @Override
      public boolean render(RenderingPluginModel rpm) throws RenderingPluginException {
  
          boolean found = false;
  
          HttpServletRequest servletRequest = (HttpServletRequest) rpm.getRequest();
          Cookie[] cookie = servletRequest.getCookies();
  
          // loop through cookies
          for (int i = 0; i &lt; cookie.length; i++) {
  
              // if test found
              if (cookie[i].getName().equals("test")) {
  
                  found = true;
              }
          }
  
          if (!found){
  
              // set cookie here
          }
      }
  }
  </code></pre>