0

I have an existing servlet and want to write some instructions to my log file on how to construct the URL needed to access my service . The basic logging service in J2EE is just fine for my purposes. The items I need are:

  1. the canonical host name (got it)

  2. the port number(s) for http connectors found in the server.xml file

  3. the intermediate path to my servlet (servlet installation folder), e.g. http://host:port/intermediate path/additional path

Using these three pieces of information I should be able to leave a breadcrumb of sorts in the log that tells administrators exactly how to configure my client-side app to access to this particular servlet instance.

Getting this information from within my implementation of HttpServlet.service() seems simple but I want to display the data during startup. Any thought on how to get it from within my implementation of HttpServlet.init()?

BigTFromAZ
  • 684
  • 7
  • 22
  • what application server are you using? Server.xml is not a standard part of J2EE, so the answer to your question will vary depending on what sort of server.xml you are dealing with. – Andy Guibert Feb 21 '16 at 00:05
  • I am using Tomcat 6 and 7 but the servlet will need to deploy to Glassfish, WAS and others. It actually works in WAS and TOMCAT at this time. I guess server.xml is implementation specific. What I was hoping for is to find the information at startup using standard Java J2EE classes and methods. – BigTFromAZ Feb 24 '16 at 17:10

0 Answers0