1 Reply Latest reply on May 24, 2011 9:48 AM by Leo van den berg

    Get url

    terrafant Newbie

      Is there any way to get my server URL from method run by CRON?
      I've tried to get HttpServletRequest, but it is null in this method (without CRON it works fine).

       HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

        • 1. Re: Get url
          Leo van den berg Master


          You can't get those values, if you don't have a real request. There are several solutions:

          • get the requestpath, from the first user who logs in and put the value in the Application scope and prevent the job to run until you have a useful value.

          • Set an application variable (for instance in your DB, in a Jboss managed property ..) and add functionality to manage it.

          I prefer the second method, because it gets saved and even if your server goes down it can retrieve the value after startup.