This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setMaxAge on cookie using JSTL

 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to set the max age of a cookie using scripting



But how do I set the max age of a cookie that I have created/set through JSTL?



I would appreciate any feedback.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way to call general methods under the JSTL/EL.

I'd set the cookie in the servlet controller for the JSP rather than on the page. Setting cookies is not a function of the view.
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just realized that the cookie is not really being set. At least no cookie files or implicit cookies show up when I "View Cookies" through Mozilla Firefox.

You mentioned I should set the cookie in the controller servlet...well I am using JSF and therefore don't normally have access to the FacesServlet. So should I resort back to scripting in this case?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a JSF fan here so you might want to have this moved to the JSF forum for advice from someone who uses it (just say the word and I'll make the shift).

But prior to resorting to scripting, I'd define a custom action (tag) to take care of the whole thing.
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear Bibeault, I'll take that advice into consideration. One more thing...what is it that you don't like about JSF?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic