• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

jstl - how to ask from jsp if an object does not exist?

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my jsp i have to make an if with jstl about an object retrived from session scope. Sometimes that object does not exist at all, and the system give me an error that object is not in the scope.
Can i use some tag for ask if the object exist without displayng errors or i have in all case to send to the page an object ( x example null for make a test as if is not null)? [ i would like to use the first method ]

Also can someone indicate to me a good reference on jstl or some tutorial(not java sun one )?

tnks
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should have a copy of the JSTL Specification open on your desk.

To test whethere an object exists you can use the empty operator. But note that this does not distinguish between and object not existing and being empty (such as a zero-length string, or empty array) if that distinction is important to you.
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<c:if test="${yourObject ne null && whatever}" scope="whatever">
your thing to do
</c:if>

<c:if test="${yourObject eq null && whatever}" scope="whatever">
your thing to do
</c:if>
 
Marco Vanoli
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
You should have a copy of the JSTL Specification open on your desk.

To test whethere an object exists you can use the empty operator. But note that this does not distinguish between and object not existing and being empty (such as a zero-length string, or empty array) if that distinction is important to you.



thnak you, can you gimme the link to specification too?
 
Bear Bibeault
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are better idioms for an if-then-else construct than using two <c:if> tags each of which had converse representations of the same expression.

One doesn't use <c:if> at all:



the other uses three <c:if> tags:



Notice that in both of these idioms the test expression appears only once, eliminating the possibility of the expression and its converse getting out of synch with each other.
[ September 11, 2005: Message edited by: Bear Bibeault ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic