aspose file tools*
The moose likes JForum and the fly likes Storing the HTTP referer header on each visit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "Storing the HTTP referer header on each visit" Watch "Storing the HTTP referer header on each visit" New topic
Author

Storing the HTTP referer header on each visit

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
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

Joined: Apr 22, 2012
Posts: 17424
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

Joined: Apr 22, 2012
Posts: 17424
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

Joined: Apr 22, 2012
Posts: 17424
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

Joined: Apr 22, 2012
Posts: 17424
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing the HTTP referer header on each visit
 
Similar Threads
Referring web page
how to find out the page the user was previously at.
Setting referer
Creating an HTTP Header
JAX-RPC web service soap message handler issues