Hi,
I hope this is in the right area ......, and I hope someone can help with this.
I am writing a portlet. It's a 'quick poll' - the idea is that the page asks the user to vote on a question using a HTML form. Users should only vote once, and given that this is an anonymous site, I originally thought a cookie would be a good way to control this.
IE. Portlet checks to see if cookie exists, if not display question and HTML form. On user submission, store results in the backend DB and set the cookie so that they are not presented with the question/form again.
I've been trying unsuccessfully to use the cookie class and adding it to the HttpServletResponse object with response.addKookie(). (Cookie deliberately spelt with a K to post into this forum)
I've subsequently read that this is not supported in a portlet as the cookie has to be written to the HTTP header before any content, and this cant be guaranteed with a portlet (as the portlet could appear anywhere on the page).
This makes sense, but now I'm stuck as to how to solve the problem.
How do I flag that this PC has already voted ?
I could use client side Javascript to set the cookie (yuck !), but will I be able to read the cookie server side with request.getKookies() ??
Or is there an alternative / better way of doing this ?
Cheers
Nathan
I hope this is in the right area ......, and I hope someone can help with this.
I am writing a portlet. It's a 'quick poll' - the idea is that the page asks the user to vote on a question using a HTML form. Users should only vote once, and given that this is an anonymous site, I originally thought a cookie would be a good way to control this.
IE. Portlet checks to see if cookie exists, if not display question and HTML form. On user submission, store results in the backend DB and set the cookie so that they are not presented with the question/form again.
I've been trying unsuccessfully to use the cookie class and adding it to the HttpServletResponse object with response.addKookie(). (Cookie deliberately spelt with a K to post into this forum)
I've subsequently read that this is not supported in a portlet as the cookie has to be written to the HTTP header before any content, and this cant be guaranteed with a portlet (as the portlet could appear anywhere on the page).
This makes sense, but now I'm stuck as to how to solve the problem.
How do I flag that this PC has already voted ?
I could use client side Javascript to set the cookie (yuck !), but will I be able to read the cookie server side with request.getKookies() ??
Or is there an alternative / better way of doing this ?
Cheers
Nathan