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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:23:43+00:00 2026-06-03T19:23:43+00:00

I am working on Google Calendar API. Whenever I create any event and enter

  • 0

I am working on Google Calendar API. Whenever I create any event and enter the description of that event having new line, It gives me error like:

“Unterminated String constant”.

I am passing that Event Description from Java to Javascript. So how to format the string having new line?

My code is:

 var EventDescription='<% =eventDetails.getEventDescription(eventIndex)%>'

    eventDetails -java class 
    getEventDEscription -Method to get the Description of event.
    eventIndex - no of the event whoes Description is needed .

It is working properly otherwise .only giving error when description is having new line.

  • 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-03T19:23:46+00:00Added an answer on June 3, 2026 at 7:23 pm

    Try to imagine yourself as the JSP container, then as the JavaScript interpreter. Or simply look at the source code of the generated HTML page.

    The line

    var EventDescription='<% =eventDetails.getEventDescription(eventIndex)%>'
    

    is interpreted by the JSP container. So eventDetails.getEventDescription(eventIndex) is executed, and the result of this method call is put in the response. Suppose the result is composed of two lines:

    line 1
    line 2
    

    So the generated JavaScript code is:

    var EventDescription='line1
    line 2'
    

    And this is invalid JavaScript code. The correct JavaScript code would be

    var EventDescription='line1\nline 2'
    

    So, you need to JavaScript-escape the result of the Java method call before putting it in the response. Look at Apache commons-lang StringEscapeUtils.escapeEcmaScript() method.

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

Sidebar

Related Questions

Iam working with C# and the Google Calendar API classes CalendarService and Event. I
I'm trying to create an event through the API and it is mostly working,
I am working on a project similar to Google calendar. To create it I
I've been trying to get Google's Calendar API working in a PHP web application,
I'm trying to create a calendar via the Google javascript API. OAuth authentication is
Actually I need to create an event in Google Calendar using my app. Every
I'm working on an app that needs to update a google calendar. By following
I've been working with the PHP api for google Calendar, and have been getting
I'm trying to get my Chrome extension working with the Google Calendar API. However,
I'm using google-api-ruby-client for working with Google Calendar API v3. The only problem I'm

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.