java - Create a cookie using HttpServletRequest? -


i've created renderingplugin, use in websphere portal, invoked serverside before sending markup client. plugin loops through cookies , if 'test' not found, i'd set cookie.

i know possible httpservletresponse renderingplugin doesn't have access object. has httpservletrequest.

is there way this?

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         (int = 0; < cookie.length; i++) {              // if test found             if (cookie[i].getname().equals("test")) {                  found = true;             }         }          if (!found){              // set cookie here         }     } } 

did try using javascript code set cookie ?

<script> document.cookie = "test=1;path=/"; </script> 

you send part of content give writer rpm.getwriter() , executed browser.


Comments

Popular posts from this blog

java - Incorrect order of records in M-M relationship in hibernate -

command line - Use qwinsta in PowerShell ISE -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -