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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:04:07+00:00 2026-06-07T00:04:07+00:00

I have hard-coded data into a .jsp file. What I want to do is

  • 0

I have hard-coded data into a .jsp file. What I want to do is populate a JavaScript array with data sent from the server.

I have tried to send the data from another .jsp page, but I cannot figure out how to convert it into a JavaScript var for me to be able to use it in my page, I also have started using JSON objects, but before I continue I just need some guidance on what the best way to do this would be.

That is: populate a JavaScipt array on a .html or .jsp file from the server. The array will then be used for Google Maps API.

Let me know if you have any questions:

thanks

  • 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-07T00:04:08+00:00Added an answer on June 7, 2026 at 12:04 am

    If it’s hardcoded, why not making it a JS variable directly?

    var foo = [{
        "name1": "value1a",
        "name2": "value2a"
    },{
        "name1": "value1b",
        "name2": "value2b"
    }];
    

    Or if it’s hardcoded in Java side and you intend to use it in JS side as well, then convert the Java object to JSON using one of the many JSON serializers/parsers available. At the bottom of json.org you can find an overview of all available JSON APIs in Java. One of them is Google Gson. It’s able to convert for example a List<SomeBean> to a JSON string as follows

    String jsonString = new Gson().toJson(someBeans);
    

    You can then just let JSP print it as if it’s a JS variable, assuming that it’s stored as a request attribute:

    var foo = ${jsonString};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have currently hard-coded in some data for a demo of a project. The
I have a hard coded URL like so: https://bupacouk.bwa.local.internal.bupa.co.uk/cash-plan-quote/quoteAction.do?getBenefitLevelDetails=getBenefitLevelDetails&productPolicyId=7841#a1 When Javascript is enabled i
I have 4 hard coded divs. After the third div I would like to
I have a hard-coded list, each list item of which has an ID. I
I have a very hard-coded XML reader below: using System; using System.Collections.Generic; using System.Linq;
I have something like this hard-coded: private string[,] m_RolesForUser = new string[,] { {John,President,Chair},
I have an NSIS installer that has the start menu folders hard-coded using this
I have a C program which has always used hard coded define statements for
I need to have a Win32 application load a hard coded AES-256 key, ideally
currently I have a web which loads excel spreadsheet data into SQL database. When

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.