• Post Reply Bookmark Topic Watch Topic
  • New Topic

Check content before adding to JSP

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I would like to check whether a field does have some content before I add it to my Table on my JSP .
How do I check it with Expression language.
Fx. if item.sellerName is empty then step over to next Item

My Code is as follow,
<c_rt:forEach items="${requestScope.itemlist}" var="item">
???if ${item.sellerName}=""???
<tr>
<td>${item.sellerName}</td>
<td>${item.testDate}</td>
<td>${item.model}</td>
</tr>
</c_rt:forEach>

 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
???if ${item.sellerName}=""???

You can use the JSTL core tag:if to achieve this.Do a search on JSTL core tag , to take a look at the options


Thanks,
Srikkanth
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srikkanth Mohanasundaram wrote:
???if ${item.sellerName}=""???

You can use the JSTL core tag:if to achieve this.Do a search on JSTL core tag , to take a look at the options


Thanks,
Srikkanth

I do not know what the values is in the field, I would like to continue if the field not is empty like
following

If field<>"";

{

}

How do write that in jstl expression langueage
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To check null and empty string condition , you can make use of the empty keyword provided in EL


EL Syntax Reference

Hope this helps.
Thanks,
Srikkanth
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srikkanth Mohanasundaram wrote:To check null and empty string condition , you can make use of the empty keyword provided in EL


EL Syntax Reference

Hope this helps.
Thanks,
Srikkanth


Thanks I had already tried it, the problem is that I get a extra row without content in my Table, so I tried to only add the row if the field did have Content.





 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, can you post the modified code ?

Thanks,
Srikkanth
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the Code which result in a empty Row since the Forms does contain a record without Values.


<c_rt:forEach items="${requestScope.Forms}" var="Form">
<c:if test="${!empty Form.Number}">
<tr>
<td>${Form.Name}</td>
<td>${Form.testDate}</td>
<td>${Form.time}</td>
</td>
</tr>
</c:if>
</c_rt:forEach>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"c_rt"? That's ancient! Are you using a really old version of JSP?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!