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

  • SEARCH
  • Home
  • 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 817193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:57:14+00:00 2026-05-15T01:57:14+00:00

How can I validate if a String is null or empty using the c

  • 0

How can I validate if a String is null or empty using the c tags of JSTL?

I have a variable named var1 and I can display it, but I want to add a comparator to validate it.

<c:out value="${var1}" />

I want to validate when it is null or empty (my values are string type).

  • 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-05-15T01:57:14+00:00Added an answer on May 15, 2026 at 1:57 am

    How can I validate if a String is null or empty using the c tags of JSTL?

    You can use the empty keyword in a <c:if> for this:

    <c:if test="${empty var1}">
        var1 is empty or null.
    </c:if>
    <c:if test="${not empty var1}">
        var1 is NOT empty or null.
    </c:if>
    

    Or the <c:choose>:

    <c:choose>
        <c:when test="${empty var1}">
            var1 is empty or null.
        </c:when>
        <c:otherwise>
            var1 is NOT empty or null.
        </c:otherwise>
    </c:choose>
    

    Or if you don’t need to conditionally render a bunch of tags and thus you could only check it inside a tag attribute, then you can use the EL conditional operator ${condition? valueIfTrue : valueIfFalse}:

    <c:out value="${empty var1 ? 'var1 is empty or null' : 'var1 is NOT empty or null'}" />
    

    To learn more about those ${} things (the Expression Language, which is a separate subject from JSTL), check here.

    See also:

    • How does EL empty operator work in JSF?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to do a axAcroPDF1.Show() According to the documentation… May 16, 2026 at 11:38 am
  • Editorial Team
    Editorial Team added an answer You could make a list of valid positions for the… May 16, 2026 at 11:38 am
  • Editorial Team
    Editorial Team added an answer You'll probably need to create a custom widget. Check out… May 16, 2026 at 11:38 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

So I have a DataGridView which is used to display a list of custom
I have a regex issue that I need help with. Its trying to validate
I'm using monorail, activerecord, and jquery. I have a form with a zip code
How can I validate radio buttons? Because this won't work at all. The radio
I am trying to validate a form in MVC. I add custom errors to
I have a control which extends the DataGridView control. I am overriding the ProcessDialyKey
Apologies for cross posting (I asked this on the Silverlight Forum but got no
I have a ViewModel which encapsulates a datasource which is a domain object. The
Currently I have a service that uses a UserNamePasswordValidator to authenticate the client user.
I have a schema here where I am trying to include/import another schema that

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.