I have a
servlet who's main purpose is to run a timed job that sends email to a list of recipients when certain error conditions occur (based upon checking a table in the DB). Included in this email is a link to a web page that the user can click on to view more details about the errors.
The issue that I'm having is that I'd like to be able to dynamically determine what the URL of the website is for the email message I send. The doGet() and doPost() are never used so I have no handle to a request object -- all I have is the ServletContext object from the init() event.
I realize that I could add a configuration parameter to the web.xml file and get it by calling servletContext.getInitParameter() but I'd rather not do that: this app could be installed on several servers and I don't want to have to change the web.xml file for each one.
Is there a way to get the URL info from the servletContext?
Thanks for the help.
- Ben