Re: Can you test for a cookie's value using c:if tag?
Shawn == Shawn Bayern [EMAIL PROTECTED] writes: Shawn On Thu, 21 Mar 2002, Matt Raible wrote: Is it possible to do the following with JSTL? c:if test=${cookie.username == 'learner'} learner /c:if Shawn Ah, I was hoping someone would ask. The answer is no, not exactly like Shawn that, but you can still use JSTL to access cookies. Shawn While web developers often have the urge to access a cookie by name, it's Shawn an urge that's best to resist; cookies aren't identified by name alone, Shawn but by name, domain, path, and security status. Thus, the best way to Shawn access a cookie is to loop over the list of available cookies, matching Shawn the one that you're interested in. Shawn Now, if you're just interested in name, that's fine; but JSTL doesn't go Shawn out of its way to support that special case. Instead, you can just write Shawn c:forEach items=${pageContext.request.cookies} var=cookie Shawn c:if test=${cookie.name == 'learner'} Shawn c:set var=cookieValue value=${cookie.value} / Shawn /c:if Shawn /c:forEach Curious. Not that I would necessarily want to do this, but from the JSTL specification, it almost seems like you could do something like this: x:set var=username select=$cookie:username/ c:if test=${username == 'learner'} So it appears that simple access to cookies is in the XML tags, but not the core tags? Please correct me if I'm confused (likely). -- === David M. Karr ; Java/J2EE/XML/Unix/C++ [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Can you test for a cookie's value using c:if tag?
Is there anyway to test if cookieValue *contains* a String, rather than just == 'String'? -Original Message- From: Shawn Bayern [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 10:36 PM To: Tag Libraries Users List; [EMAIL PROTECTED] Subject: Re: Can you test for a cookie's value using c:if tag? On Thu, 21 Mar 2002, Matt Raible wrote: Is it possible to do the following with JSTL? c:if test=${cookie.username == 'learner'} learner /c:if Ah, I was hoping someone would ask. The answer is no, not exactly like that, but you can still use JSTL to access cookies. While web developers often have the urge to access a cookie by name, it's an urge that's best to resist; cookies aren't identified by name alone, but by name, domain, path, and security status. Thus, the best way to access a cookie is to loop over the list of available cookies, matching the one that you're interested in. Now, if you're just interested in name, that's fine; but JSTL doesn't go out of its way to support that special case. Instead, you can just write c:forEach items=${pageContext.request.cookies} var=cookie c:if test=${cookie.name == 'learner'} c:set var=cookieValue value=${cookie.value} / /c:if /c:forEach I explain this in more detail in my book; interestingly enough, I just wrote the section describing techniques like this. -- Shawn Bayern Author, JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Can you test for a cookie's value using c:if tag?
On Sat, 23 Mar 2002, Matt Raible wrote: Is there anyway to test if cookieValue *contains* a String, rather than just == 'String'? No. For that, you'll need a custom taglib (or, of course, the dreaded scriptlet). :) Ultimately, I'd personally like to see some string support in JSTL (like Bay's string taglib); hopefully, that'll come up in JSTL 1.1. -- Shawn Bayern Author, JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Can you test for a cookie's value using c:if tag?
Is it possible to do the following with JSTL? c:if test=${cookie.username == 'learner'} learner /c:if -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Can you test for a cookie's value using c:if tag?
On Thu, 21 Mar 2002, Matt Raible wrote: Is it possible to do the following with JSTL? c:if test=${cookie.username == 'learner'} learner /c:if Ah, I was hoping someone would ask. The answer is no, not exactly like that, but you can still use JSTL to access cookies. While web developers often have the urge to access a cookie by name, it's an urge that's best to resist; cookies aren't identified by name alone, but by name, domain, path, and security status. Thus, the best way to access a cookie is to loop over the list of available cookies, matching the one that you're interested in. Now, if you're just interested in name, that's fine; but JSTL doesn't go out of its way to support that special case. Instead, you can just write c:forEach items=${pageContext.request.cookies} var=cookie c:if test=${cookie.name == 'learner'} c:set var=cookieValue value=${cookie.value} / /c:if /c:forEach I explain this in more detail in my book; interestingly enough, I just wrote the section describing techniques like this. -- Shawn Bayern Author, JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]