title: JasperReports: How to construct the title header depending on parameters
body: <p>How to construct the title header depending on parameters?</p>
  
  <p>Example, I have one reports by date, weekly, month and year. I have a parameter but I don't know how to display it in header.</p>
  
  <p>What I want is:</p>
  
  <pre><code>If I put parameter $P{date1} and $P{date2} then it will show 'Date range from $P{date1} and $P{date2}' for header 1
  
  else if parameter $P{w}$P{month}$P{year} then 'For weekly $P{w}$P{month}$P{year}' for header 2
  
  else if parameter $P{month}$P{year} then 'For monthly $P{month}$P{year}' for header 3
  
  else if parameter $P{q}$P{year} then 'For quarter $P{q}$P{year}' for header 4
  
  else if parameter $P{year} then 'For yearly $P{year}' for header 5
  </code></pre>
  
  <p>UPDATE:-
  i have new problem when i run the report,my output not display correctly.
  This is my code:-</p>
  
  <pre><code>&lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Company Profile by Date Registered" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true"&gt;
      &lt;property name="ireport.zoom" value="1.0"/&gt;
      &lt;property name="ireport.x" value="0"/&gt;
      &lt;property name="ireport.y" value="0"/&gt;
      &lt;parameter name="daterangefrom" class="java.lang.String"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;parameter name="daterangeto" class="java.lang.String"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;parameter name="monthy" class="java.lang.String"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;parameter name="yrs" class="java.lang.String"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;parameter name="quarter" class="java.lang.String"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;parameter name="weeks" class="java.lang.String"&gt;
          &lt;defaultValueExpression&gt;&lt;![CDATA[]]&gt;&lt;/defaultValueExpression&gt;
      &lt;/parameter&gt;
      &lt;queryString&gt;
          &lt;![CDATA[select a.entered,
  a.modified,
  a.org_id,
  a.name,
  a.organization_type,
  c.description as companygroup,lead,
  a.industry_temp_code,
  b.description,
  a.equity_structure,a.operation_date from organization a
  left join lookup_industry_group b on a.industry_temp_code = b.code
  left join lookup_company_group c on c.code = a.company_group
  left join ticket d on d.org_id = a.org_id
  where
  ((d.entered BETWEEN $P{daterangefrom} AND $P{daterangeto}) or ($P{daterangefrom} =' ' AND $P{daterangeto} =' '))
  AND
  ((datename(month,d.entered) = $P{monthy}) or ($P{monthy} = ' '))
  AND
  ((datename(year,d.entered) = $P{yrs}) or ($P{yrs} = ' '))
  AND
  ((datepart(qq, d.entered) = $P{quarter}) or ($P{quarter} = ' '))
  AND
  ((DATEPART(day, d.entered - 1) / 7 + 1 = $P{weeks}) or  ($P{weeks} = ' '))]]&gt;
      &lt;/queryString&gt;
      &lt;field name="entered" class="java.sql.Timestamp"/&gt;
      &lt;field name="modified" class="java.sql.Timestamp"/&gt;
      &lt;field name="org_id" class="java.lang.Integer"/&gt;
      &lt;field name="name" class="java.lang.String"/&gt;
      &lt;field name="organization_type" class="java.lang.String"/&gt;
      &lt;field name="companygroup" class="java.lang.String"/&gt;
      &lt;field name="lead" class="java.lang.String"/&gt;
      &lt;field name="industry_temp_code" class="java.lang.Integer"/&gt;
      &lt;field name="description" class="java.lang.String"/&gt;
      &lt;field name="equity_structure" class="java.lang.String"/&gt;
      &lt;field name="operation_date" class="java.sql.Timestamp"/&gt;
      &lt;title&gt;
          &lt;band height="79" splitType="Stretch"&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement x="18" y="14" width="537" height="41" isRemoveLineWhenBlank="true"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[(($P{daterangefrom} != null) &amp;&amp; ($P{daterangeto} != null)) ?  "Date range from " + $P{daterangefrom} + " and " + $P{daterangeto}
  : (($P{weeks} != null) &amp;&amp; ($P{monthy} != null) &amp;&amp; ($P{yrs} != null)) ? "For weekly " +$P{weeks} + $P{monthy} + $P{yrs}
  : (($P{monthy} != null) &amp;&amp; ($P{yrs} != null)) ? "For monthly " + $P{monthy} + $P{yrs}
  : (($P{quarter} != null) &amp;&amp;  ($P{yrs} != null)) ? "For quarter " + $P{quarter} + $P{yrs}
  : (($P{yrs} != null)) ? "For yearly " + $P{yrs} : null]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/title&gt;
  &lt;/jasperReport&gt;
  </code></pre>