• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Storing the HTTP referer header on each visit

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I'm a new to JForum, so go slowly.

I need to get and store the "referer" header from the HTTP request for each session, to track how users came to my site, regardless of their entry point into the site. I'm using jsp to read the HTTP headers. If I read the referer from within header.jsp then the referer is the forum page, and not the external referer.

How can I read the original headers on any forum page on my site?

Thanks,
Mike
[originally posted on jforum.net by MJB]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Update: I notice that I can add JS to the forum templates, and use it to read the referer header, but I'll have to send it to the server (probably using JS XMLHTTPRequest to store it in the session). Is there a cleaner way to do this?

Thanks,
Mike
[originally posted on jforum.net by MJB]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might be able to use the JForumContext FreeMarker variable. This is added to all templates. You can get the JForumRequest object from that with getRequest(). Then you can get header values with getHeader( ...).

Some thing like:



Note I'm not sure if you can do this with a double call. You may have to do it with two assigns. One to get the request object and on to get the header.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's exactly what I wanted to do. And you can chain the calls - no need for the two assigns.

Is there a way using freemarker to pass the value of getHeader() to a static function in a POJO?

Thanks for the help,
Mike
[originally posted on jforum.net by MJB]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe... depends on what you want. I think you may be able to assign a FreeMarker var to a new object and then call the setXXX() method of a POJO. Of course, design wise I shudder at using the View component to do Controller logic... but sometimes you gotta do what you gotta do...
[originally posted on jforum.net by monroe]
 
I am Arthur, King of the Britons. And this is a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic