http://www.opencms-forum.de 的一篇 page hit counter

 

RIA知识库 
flex 
RIA 

Jason
Stranger



Joined: Aug 20, 2010
Posts: 5
Status: Offline

Page Hit Count Reply to this Post
Reply with Quote

I have written some JSP code on template JSP to update the page hits count when the page is accessed. The code is ok on offline mode, but when I check it on online mode, the count does not get update. May I know where I should my JSP so that it will be execute everytime?

 

Flo
Advanced Member


Joined: May 7, 2004
Posts: 452
Status: Offline
Re: Page Hit Count Reply to this Post
Reply with Quote

Hi,

what exactky are you doing in your jsp? Are you writing to the VFS? If yes, you have to switch to the Offline project first and publish the modified resource afterwards.

This can be done using methods in CmsRequestContext and CmsPublishManager
----------------------------------------
/**
* Florian Hopf
* Synyx GmbH & Co. KG
*/

 

Jason
Stranger



Joined: Aug 20, 2010
Posts: 5
Status: Offline

Re: Page Hit Count Reply to this Post
Reply with Quote

I use the OAMP Counter Module in my JSP. It will save the count to database. The following is the code snippet:

String uri = cms.getRequest().getParameter("uri") == null ? cms.getRequestContext().getUri() : cms.getRequest().getParameter("uri");

int pageCount = getCounterManager().incrementCounter(uri);

out.println("count = " + pageCount);

On offline mode, everytime I refresh the page, my count increase one. But on online mode, the page count I get remain the same. Seems the page is cached and JSP code snippet does not get executed.

 

Flo
Advanced Member


Joined: May 7, 2004
Posts: 452
Status: Offline
Re: Page Hit Count Reply to this Post
Reply with Quote

Yeah, caching might be the reason. Try to set the cache property for the elements displaying and writing the hit to "never"
----------------------------------------
/**
* Florian Hopf
* Synyx GmbH & Co. KG
*/

 

Jason
Stranger



Joined: Aug 20, 2010
Posts: 5
Status: Offline

Re: Page Hit Count Reply to this Post
Reply with Quote

Yes, it does work if I set cache from "uri;element" to "never".

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值