How to access HTML Request data

Each Freemarker cloudCMS page has access to pre-defined set of variables. Following are implicit variables available to each page.

Note : All this variables are read Only.

"wbrequest" Attributes

wbrequest have two custom attributes "pageName" and "pageGroup" which denotes current requested page. You can access other request parameters using following syntax :

 wbrequest.<varname> 
or
wbrequest["var name"] 
For multi-value parameter (like "?id=1&id=2") cloudCMS will set Freemarker sequence with all the values. In "wbheader" all the parameters prefix with "_" are custom variables added by cloudCMS.

Try following example links to see how the request information changes below :
HowTo.accessRequestHeader?myparam=somevalue¶m2=somevalue2
HowTo.accessRequestHeader?xyz=1&xyz=2


Following is the dump of current HTTP Request/Header/Session data :

Loop through all HTTP Request
  • pageName = accessRequestHeader
  • pageGroup = HowTo

  • Loop through all HTTP Header
  • Cookie = JSESSIONID=9ciYEw98XGxz9D4pA9Qy_g
  • _remoteHost = 38.107.179.210
  • Host = cloudcms.sheelapps.com
  • _remoteAddr = 38.107.179.210
  • X-AppEngine-CityLatLong = 34.052234,-118.243684
  • User-Agent = CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
  • _queryString =
  • x-cc-id = ccc01-01
  • X-Google-Apps-Metadata = domain=sheelapps.com
  • X-AppEngine-Region = ca
  • Pragma = no-cache
  • Cache-Control = no-cache
  • X-AppEngine-City = los angeles
  • _pathInfo =
  • Accept-Language = en-us,en;q=0.5
  • _requestURL = http://cloudcms.sheelapps.com/HowTo.accessRequestHeader
  • _requestURI = /HowTo.accessRequestHeader
  • Accept-Charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7
  • X-AppEngine-Country = US
  • _contextPath =
  • X-Zoo = app-id=cloudcmsdemo,domain=sheelapps.com
  • Accept = text/html,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
  • X-AppEngine-Default-Namespace = sheelapps.com

  • Loop through all HTTP session
  • org.vraptor.scope.ScopeType_FLASH ={}

  • Source code of above example

    
    <h4>Current Request Information : </h4>
    <strong>Loop through all HTTP Request </strong><br/>
    <#assign keys = wbrequest?keys>
    <#list keys as key><li>${key} = 
    
    <#if (wbrequest[key])?is_sequence>
    <#list wbrequest[key] as val> ${val}, </#list>
    <#else>
    ${wbrequest[key]}
    </#if> 
    </li> 
    </#list>  
    
    <br/>
    <strong>Loop through all HTTP Header </strong><br/>
    <#assign keys = wbheader?keys>
    <#list keys as key><li>${key} = ${wbheader[key]} </li> </#list>  
    
    <br/>
    <strong>Loop through all HTTP session </strong><br/>
    <#assign keys = wbsession?keys>
    <#list keys as key><li>${key} =${wbsession[key]}</li> </#list>  
    
    
    
    

    blog comments powered by Disqus

    Last Modified : Jul 10, 2009 3:18:55 PM