Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
import environment variable inside html and javascript

I have a maven project with folders like myproject/src/main/resources/public. I am using this maven project just to make a war and deploy my UI code (containing HTML5, JavaScript(with jQuery), CSS etc) to tomcat server and nothing java related.

And inside public folder, I have index.html and builder.js files defined.

index.html which has the following line:

<button type="button" id = "bButton " onclick="location.href='https://myserver-dev.com/Builder/builder.html'">Builder</button>

And another JS file builder.js where I am setting env variable like this:

//  var envURL = "http://localhost:8080";
  var envURL = "https://myserver-dev.com";
  //var envURL = "https://myserver-test.com";

I was thinking of creating a separate JS file, maybe something like properties.js or env.js and put the following in it so that I can just import it in html and js files whenever needed:

//  var envURL = "http://localhost:8080";
  var envURL = "https://myserver-dev.com";
  //var envURL = "https://myserver-test.com";

If I do that what would be the best way to get the envURL inside index.html and builder.js at appropriate places?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!