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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:47:02+00:00 2026-06-12T12:47:02+00:00

I need to initialize complex javascript code as an string. But that javascript code

  • 0

I need to initialize complex javascript code as an string. But that javascript code contains semicolon and ” mark. I know I can escape ” mark using \”. But I don’t know how to escape semicolon.

<script type="text/javascript"><!--
google_ad_client = "8888888888888";
/* Error Page Ads */
google_ad_slot = "8888888";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

I need to initialize above code as,

String complexString = "Above code here";

I can’t concatenate slices of code, because that way ; will be removed. Right?

This is for Servlet. I may be foolish, but pardon me.

  • 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-12T12:47:03+00:00Added an answer on June 12, 2026 at 12:47 pm

    I think what you really want to do is escape the quote characters in your javascript not your semicolon characters.

    So ultimately you would want

    String complexString = "<script type=\"text/javascript\"><!--
    google_ad_client = \"8888888888888\";
    /* Error Page Ads */
    google_ad_slot = \"8888888\";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>  
    <script type=\"text/javascript\"
    src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">  
    </script>"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to initialize few objects, it can take a while so I want
I'm writing a web application and need to initialize some parameters that I'm pulling
I need to initialize a set of static String values stored in an XML
I have WCF service that is hosted in IIS . I need to initialize
I need to deserialize JSON string to custom complex objects. For example lets say
I need to initialize a session var as array. Where i do that? when
I have a class that subclasses UITableViewCell. I need to initialize some of the
I'm developing a few custom ant tasks that all need to initialize the same
I am writing a program in C++ and I need to initialize an array
In some languages, like php, you don't need to manually initialize each dimension of

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.