Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:43:17+00:00 2026-06-11T18:43:17+00:00

Say my java code has List<String> listS =null and i pass this to my

  • 0

Say my java code has List<String> listS =null and i pass this to my template file.

Now i want to make sure that if list has some data then only do something.

I have tried

<#if listS = null>
AND
<#if !listS>
AND
<#if listS?size=0>

But none of these seem to be working. I have some logic i my java code ; through which , if some condition is true, then i new this listS and populate it.

Hence i need to know if the listS has been populated or is null only, in my template file.

How do i do this? Thanks.

EDIT: Also, i have a list of Structures, each containing this listS,(populated or not is a different issue), and i am passing the entire list of structure, hence passing a boolean value to the template file along with my list of Structures is not possible, since i will have to traverse within each list, and that traversal I want to do in the template file itself.

EDIT 2: For those who know what’s Java null, FreeMarker 2.3.x treats them as missing values. Simply, the template language doesn’t know the concept of null. For example, if you have a bean that has a maidenName property, and the value of that property is null, then that’s the same as if there were no such property at all, as far as the template is concerned (assuming you didn’t configured FreeMarker to use some extreme object wrapper, that is). The result of a method call that returns null is also treated as a missing variable (again, assuming that you use some usual object wrapper). See more in the FAQ.

Freemarker Manual

But I still havent got the answer for how to make it work, if at all I can.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:43:19+00:00Added an answer on June 11, 2026 at 6:43 pm

    Use the has_content built-in:

    <#if list5?has_content>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I want to create a sort of Pre-processor for existing java code, so
Say suppose I have the following Java code. public class Example { public static
In another discussion , someone say something about run the java code on its
Does Java guarantee array initialization? Let's say I use the code char[] uuid =
I'm trying to open a file in a Java program (say Program.java ) using
In java they say don't concatenate Strings, instead you should make a stringbuffer and
I have code that looks like this: public class Polynomial { List<Term> term =
I am currently working on some Java code that has a lot of ActionListeners
Let’s say I have table/list like this n=3 in this case, but n can
I have to execute a java code using batch script where java code has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.