[Java] Cookies in VAP

I found out a few more things about using cookies in the VAP portal. I blogged earlier about this, but I found a way to set cookies from the grid-file of the portal. It's not possible setting cookies through the response.addCookie() method, but since the grid also controls the <HEAD> section of the HTML page, use the <META> tag:

<meta http-equiv="set-cookie" content="cookiename=cookievalue; path=/">

This works just fine, but if you want to grab the cookies from a JSR 168 portlet, you must do that from a JSP page in the portlet applications. To write out all cookies you can see from the portlet:

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

<portlet:defineObjects/>

 

Hey, these are my cookies:

<p>

<%

   Cookie[] cookies = request.getCookies();

   for(int i=0; i<cookies.length; i++)

   {

      Cookie cookie = cookies[i];

%>

 name=<%=cookie.getName()%>,

 value=<%=cookie.getValue()%><br>

<%

   }

%>

I've not found any way to do it from within the portlet class. Nor have I found a way to set a cookie from a portlet.

There is another way to send "parameters" to a JSR 168 portlet from a link or a button or a form in the "portal wireframe". For example from a style file. I'll write about that later, need to run now.

No Comments