Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reuse application constants written inside Java classes within javascript?

Is there is a way to reuse public static final constants defined inside Java classes with the javascript files ?

Or is there a better way to define such constants so that they can be reused by both java & JavaScript ?

like image 830
Rajat Gupta Avatar asked Feb 19 '26 22:02

Rajat Gupta


1 Answers

A very simple solution would be to store your config as JSON on the server side, then have the server inject that into the HTML response to the client.

The server can read the JSON on startup and keep it in a singleton object.

like image 194
Abdullah Jibaly Avatar answered Feb 21 '26 11:02

Abdullah Jibaly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!