Eliminate single quote

Posted on 2006-04-12
Last Modified: 2010-04-01

batchMsg+=" ' " + batchID +" ' "

When I use <%=batchMsg%> it displays the single quote.
How to don't display the single quote?

Thank you.

Question by:mayachoy
    LVL 92

    Accepted Solution

    batchMsg+=" " + batchID +" "
    LVL 3

    Assisted Solution

    Hi mayachoy,
    > When I use <%=batchMsg%> it displays the single quote.
    > How to don't display the single quote?
    > Thank you.

    <%=batchMsg..replaceAll("'", "")%>
    You may need a null check....
    LVL 12

    Expert Comment

    grrrrrr, can I get a word in edgewise ;)

    checking for null always seems liek a good idea!  ...and el_dios, you've got one too many dots in there for the replaceAll call:

    <%=batchMsg==null?"":batchMsg.replaceAll("'", "")%>

    ...I'm confused that you sound confused by this?  You're adding the single quotes to the string using the concatination operator.  When you add those single quotes like that, they become a part of the string.  Why are you quoting the batchID anyway, if it's for query there are NO quotes around integer values, so the first suggestion may not be so bad, but no need to append an empty string at the end?

    batchMsg+="" + batchID;

    is batchID an integer variable?
    LVL 23

    Expert Comment

    batchMsg=batchMsg+""+ batchID;

    will solve your problem don't Complicate the things.
    LVL 4

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    Running Java Servlet inside Eclipse Luna 6 127
    Javascript onclick event 4 97
    maven project import to eclipse problems 13 90
    JSP Popup page 2 82
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    Digital marketing agencies have encountered both the opportunities and difficulties that emerge from working with a wide-ranging organizations.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now