Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

<logic:empty> tag question

Thread view: 
Steve - 10 Aug 2006 02:16 GMT
In the following code, why it prints "LOGIC: EMPTY" on the console? I
expect to see "LOGIC: NOT EMPTY" since ss is not null, and it should
pass the test <logic:notEmpty name="ss">. What I am missing here?
Please advice. Thanks!!

<%
  String ss = "JJ";
  System.out.println("from jsp = " + ss);
%>
<%
if (ss == null)
    System.out.println("SS = null");
else
    System.out.println("SS != null");
%>

<logic:empty name="ss">
    <% System.out.println("LOGIC: EMPTY " ); %>
</logic:empty>
<logic:notEmpty name="ss">
    <% System.out.println("LOGIC: NOT EMPTY " ); %>
</logic:notEmpty>

<c:if test="ss != null}">
    <% System.out.println("JSTL LOGIC: NOT EMPTY " ); %>
</c:if>

output
==========
[8/9/06 16:19:57:470 PDT] 7d42a949 SystemOut     O from jsp = JJ
[8/9/06 16:19:57:470 PDT] 7d42a949 SystemOut     O SS != null
[8/9/06 16:19:57:470 PDT] 7d42a949 SystemOut     O LOGIC: EMPTY
[8/9/06 16:19:57:470 PDT] 7d42a949 SystemOut     O JSTL LOGIC: NOT
EMPTY
Tobias Schierge - 10 Aug 2006 09:18 GMT
Hi,

> <%
>    String ss = "JJ";
[quoted text clipped - 17 lines]
> <% System.out.println("JSTL LOGIC: NOT EMPTY " ); %>
> </c:if>

You are mixing references to bean variables and locally declared variables.
Please get some deeper understanding of the stuff. Another Advice would be
to ban all scriptlets from JSP to avoid lots of trouble.

try:  request.setAttribute("ss","jj"); or
     pageContext.setAttribute("ss","jj");

Regards,

Tobias


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.