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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -