Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

c:set with no value

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello !

I read in jstl spec that tag c:set with no attribute value removed the attribute specified in var properties. But i see that the container does not

removed my attribute.It just replace the oldest value by an empty string.

here my code
<c:set var="var1" scope="session"/>

It doesn't removed attribute var1. It just cleared it.

Has anybody already tested this functionality??

Thank's
 
Marshal
Posts: 25671
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Chris Siciliano wrote:Has anybody already tested this functionality??



My guess is that since the spec was written 10 years ago, you aren't the first one to test it. So let's see your test.
 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The quote you mention relates to Syntax #1 where you specify a value attribute.
You have no value attribute specified, so this is Syntax #2, which your quoted rule does not apply to.
In Syntax #2, the value is evaluated from the body of the tag. In this case, empty String.

So this is behaving exactly as specified. If you do a set tag with a value attribute evaluating to null, then the attribute does get removed:
Snippet of JSP proving this:



(Disclaimer: Scriptlet code in this snippet is for example purposes only, to demonstrate that the attribute is indeed removed. I do not condone the use of scriptlet code in any normal JSP)
 
Chris Siciliano
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stefan,

Thank you for your explanation.

Indeed when i put a explicit null value --> ${null} --> it removed the attribute but without value it just cleared the String.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An empty body is equivalent to specifying "" as the value of the attribute
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic