Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Module Name Programmatically

I add a new Google Cloud Module to my Android Studio project to create a backend servlet that I build as a WAR and deploy to Jetty (or to Google Cloud). The WAR file name is <module-name>.war (eg. backend.war). When deploying the WAR file to Jetty the servlet's URL is https://<server-fqdn>/<module-name>. The Android client code has to HTTP POST to that URL. How do I get the servlet module name programmatically in the Android client code so it can hit the servlet? Even if I later change the servlet module name, I don't want to have to revise the Android client Java code to keep it synced with the backend servlet name.

like image 249
Matthew Avatar asked Mar 31 '26 00:03

Matthew


1 Answers

Module names are only available at compile time. You cannot get them programmatically at run time. Instead, you should will need a way to specify the URL in your code. One way to do this is to have a class with a public static final String that is accessible by all code that needs to know the URL.

like image 146
Code-Apprentice Avatar answered Apr 02 '26 08:04

Code-Apprentice



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!