wood burning stoves 2.0*
The moose likes JSP and the fly likes setMaxAge on cookie using JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "setMaxAge on cookie using JSTL" Watch "setMaxAge on cookie using JSTL" New topic
Author

setMaxAge on cookie using JSTL

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
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

Joined: Jan 10, 2002
Posts: 61448
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
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

Joined: Jan 10, 2002
Posts: 61448
    
  67

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

Joined: Oct 14, 2004
Posts: 205
Thanks Bear Bibeault, I'll take that advice into consideration. One more thing...what is it that you don't like about JSF?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setMaxAge on cookie using JSTL