tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Any way to configure a javascript/html war with deployment-time properties?
Date Mon, 15 Aug 2016 21:26:41 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

David,

On 8/15/16 3:39 PM, KARR, DAVID wrote:
> I'm using TomEE, but I think this question is Tomcat-specific, if 
> there's any solution at all.
> 
> I have a WAR that is a "pure" webapp, with only javascript, css,
> and html.  The javascript connects to a REST service at a defined 
> host:port.  The host:port is currently hardcoded in a javascript 
> variable.
> 
> I really need to be able to configure this host:port at deployment 
> time.  I know how to do this sort of thing with Java apps, but I'm
> at a loss to see how to do this conveniently for a non-Java war.
> 
> How can I rearrange this solution so that I can change the
> host:port the WAR uses at deployment time?

If your content is non-dynamic, then it's .. non-dynamic. There is no
problem returning a dynamically-built javascript source file if you'd
like.

You have a lot of choices for how to dynamically-build a source file
like that, but if you were to use JSP, it could look something like this
:


// This is my "pure" webapp, with only javascript, css, and html
var serviceBaseURL = '<%=
request.getServletContext().getAttribute("baseURL") %>';

// Here is the rest of your application.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJXsjORAAoJEBzwKT+lPKRYr+YQAJ176abKGbiOxE1PSoXBzZ1B
dMELhokb9/nIsS4h9JkJ4MU+paQit/Hl4vjWYqLL9wyP7zzr3qM40gWlTLT5VnyB
afpt+q3IjJihgsAzMrCe+2SHBr6kSVctwFtiUu0mHFlgpO1j/HtZ/Eu96+0IRZln
Deqn2Ci29P2S10cwTAWNE+vByE+YJiG857pwJ+M25HXoHXheJumqE0SqK2pqVCcT
DkoB86qTEe8wVEtKImNwR8m8NhWEthca860n/Zvo1nhdA1+oXtJU2F89Khu5v3nW
bDErUdks0jUErMtCQFRCl4iq6KxMbWFLmv2fV8weIoM9X6d4w1/0u9MIHXkxOjSd
mOWKH0ECdldk2alz45aX3CFxeKjnx8o6jlyc2oCyUJZgSDck7A01a3FwjSEqz2+T
XqZYOzgXV1C/7NC+ocG0vK7G6YVRPjruq1k94/+QwaebS/oOqgNDsP4t+R5ZUoJQ
5pOyVcH3RzJqsobtjthR277xHv3CwDGqGbZFJhc7MLegs9nRySX7vOAaloC8/61R
zMBumUdH3Wpee/8tTs5gOPcsEkjGagVXlCrpxaTjKXzT496f0Zc+33ZJeypVG1OF
zb6jqZyK3Q3Z3Hiinx84B+kX5lhIb9ezq5vlthnzmmjluExL9gvjF1p5rd8qFc8m
QLuYNTyl12udOjD57SUn
=Rf7X
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message