2 Replies Latest reply on Feb 5, 2009 2:24 PM by Binesh Gummadi

    Domain URL and page parameters

    zeeman Novice

      I'm using seam 2.1 on jBoss (need to run it on glassfish as well).

      I'm not sure if I'm on the right track here.

      When a user registers, I need to send a confirmation email to the user. The email will have a link to confirm registration (it has some Id). How can I get the full domain URL so I can add to it as a page parameter? There will be a page that has a bean that will take the page parameter and update the user's account as confirmed in the db. Is this the correct way to do this?

      for example I plan to send an email with this structure http://mydomain:8080/myAppname/registerationConfirm.seam?id=12443

      I should not hard code the domain and app name. I need to get that from the app server and append registerationConfirm.seam?id=12443 to it.
      I see that servletContext has some methods to get urls. But I cannot figure out which method that returns the full domain path. I used some of the methods and they only return the relative path to the project with FacesContext.currentInstance().externalContext() (bad spelling here)
        • 1. Re: Domain URL and page parameters
          zeeman Novice

          Never mind, I found how it's done in wiki example. They just read the url to use from db, it's configurable. I thought I would be able to get it from the container but I guess not.

          • 2. Re: Domain URL and page parameters
            Binesh Gummadi Novice

            I guess you can. It really depends on what approach you want to take based on your requirement. You can save it in the database or you can make it a configurable parameter and inject it into seam components via seam.components or read it from the container.

            There is no single method to give you the URL. You should construct it. You can define the following


            <factory name="currentRequest" value="#{facesContext.externalContext.request}" />

            Your Java class

            HttpServletRequest request;
            public String getDomainNameWithContext() {
                return request.getScheme() + ":"+ request.getServerPort() +"//" + request.getServerName() + request.getContextPath();