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 6002295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:57:27+00:00 2026-05-23T00:57:27+00:00

How do I get the promoPrice variable to print as part of the string

  • 0

How do I get the promoPrice variable to print as part of the string ONLY $4.67?

<c:set var="promoPrice" value="4.67" />
<p>${(promoPrice != null) ? "ONLY $${promoPrice}" : "FREE"}</p>
  • 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-23T00:57:28+00:00Added an answer on May 23, 2026 at 12:57 am

    If you’re already on EL 3.0 (Java EE 7; WildFly, Tomcat 8, GlassFish 4, etc), then you could use the new += operator for this:

    <p>${not empty promoPrice ? 'ONLY $' += promoPrice : 'FREE'}</p>
    

    If you’re however not on EL 3.0 yet, then use EL 2.2 (Java EE 7; JBoss AS 6/7, Tomcat 7, GlassFish 3, etc) capability of invoking direct methods with arguments, which you then apply on String#concat():

    <p>${not empty promoPrice ? 'ONLY $'.concat(promoPrice) : 'FREE'}</p>
    

    Or if you’re even not on EL 2.2 yet, then use JSTL <c:set> to create a new EL variable with the concatenated values just inlined in value:

    <c:set var="promoPriceString" value="ONLY $${promoPrice}" />
    <p>${not empty promoPrice ? promoPriceString : 'FREE'}</p>
    

    In your particular case, another way is to split the expression in two parts:

    <p>${not empty promoPrice ? 'ONLY $' : 'FREE'}${promoPrice}</p>
    

    If ${promoPrice} is null or empty, it won’t be printed anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Get value out of DateTime column if null to return String.Empty else DateTime.ToShortDateString What
I get FIX message string (ASCII) as ByteBuffer. I parse tag value pairs and
Get month of a given date which is stored in a PHP time variable
get_by_my_column If I only want to match the get_by portion of the above string,
get-value call returns an expression instead of concrete value #b01 : sat (((trans_local true
Get object 's array value in php $obj = new Basecamp($bcUrl, $bcApikey, 'X', 'simplexml');
// GET: /Product/Delete/5 public ActionResult Delete(int id) { var res = (from r in
// get friends public Cursor getFriends(){ Cursor c = dataBase.query(SqConstants.FRIENDS_TABLE_LOCAL, null, null, null, null,
//get choice input int n; scanf (%d,&n); // print the option that the user
Get 'n' random string from a Arraylist of string. Where n= number of string

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.