1 Reply Latest reply on Aug 15, 2006 12:19 AM by Jason Long

    getting referer

    nepoez nugget Newbie

      Is there a way to grab the referer in a backing bean? For statistics purpose.

        • 1. Re: getting referer
          Jason Long Master

          I use the following as a page action to log access to my application.

          In the @Create method I set the request. I am only interested in the "User-Agent" header, but I am sure you can get the referrer as well.

          public class AccessManagerBean implements Serializable, AccessManager {
           private static final long serialVersionUID = 2947953361734540770L;
           @EJB AccessDAO accessDAO;
           @EJB UsrDAO usrDAO;
           @Logger Log log;
           @DataModel(scope = ScopeType.PAGE)
           private List<Access> accessList;
           @In(required = false)
           @Out(scope = ScopeType.PAGE, required = false)
           private Access accessNew;
           private FacesContext facesContext;
           public void getList()
           accessList = accessDAO.getAllAccesss();
           public void getNew() {
           accessNew = new Access();
           private HttpServletRequest request;
           public void setup() {
           request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
           public String select() {
           return null;
           public String update() {
           return null;
           public String add() {
           Access access = new Access();
           access.setStartDate(new Date());
           access = accessDAO.makePersistent(access);
           return null;
           private void clear(){ }
           public String delete()
           return null;
           @Destroy @Remove
           public void destroy() { }