I have a web-page created with JavaServer Pages (JSP) and with significant JavaScript (JS) that makes calls to other servers. The URL that the page talks to depends on what server (read: environment) I deploy to.
I have two possible strategies (at least) that I can use.
- I can define a server name constant in a JS file and use a script tag on that web page.
- I can write a JS variable with the JSP page, as some sort of dynamic content.
I'm leaning heavily on strategy 1, but am unsure if either of these is really better. I'd like to know what best practice is, and why.