How to get jsessionId from request header to set it into the whole session

Request Header Value
Cookie JSESSIONID=5C2B1867AB978DED75E17566E5D7CA6C

The value of jsession id gets changed randomly on site. Through screen scraper tool how do we capture this jsession id. We tried to set this cookie into the session but as its value gets changed randomly, so that the session gets failed. Kindly please help us to capture this jsession id.

Really you would just want to

Really you would just want to scrape it and save is as a session variable. In the proxy, where you've captured all the HTTP responses, do a find for JSESSION= in the responses and you should find it, usually on either the page with a login form or during the login process.

HTTP Header request jsessionId

For the below given URL we tried to capture the jsessionId from HTTP response but its getting failed because the jsessionId of HTTP request and response is different.
It works for HTTP request jsessionId by using setCookie() method but this jessionId value gets changed randomly on the site.

http://planning.broxbourne.gov.uk/Planning/lg/plansearch.page

How do we fix this issue?

diptirmaya, I set up a test

diptirmaya,

I set up a test scraping session using the information you provided. When I ran my scrape I found that the value of jsessionid actually stayed the same during the entire session.

If you'd like, you're welcome to post the proceedure you're using. Please keep it very simple.

Something like...

- I ran the following URL as a scrapeable file inside a scraping session.
http://planning.broxbourne.gov.uk/Planning/lg/plansearchloc.page
- I extract the value of jsessionid from the Last Response and saved it as a session variable.
- I then ran another scrapeable file where I first call a script containing the following.
session.setCookie("planning.broxbourne.gov.uk","jsessionid",session.getv("jsessionid"));
- After the scrapeable file finishes I viewed the Last Response and found the value of jsessionid was.....

-Scott

jsession id is not passed in response

I tried as you suggested but it doesn't worked. The jsession id is still not available in the last response.Please find the attached session i tried,

<?xml version="1.0" encoding="UTF-8"?>
<scraping-session use-strict-mode="true">
<script-instances><owner-type>ScrapingSession</owner-type><owner-name>BroxBourne_Scraping_Session</owner-name></script-instances>
<name>BroxBourne_Scraping_Session</name><notes></notes><cookiePolicy>0</cookiePolicy><maxHTTPRequests>1</maxHTTPRequests><external_proxy_username>guest1</external_proxy_username><external_proxy_password>guest1</external_proxy_password><external_proxy_host>10.0.4.254</external_proxy_host><external_proxy_port>8080</external_proxy_port><external_nt_proxy_username></external_nt_proxy_username><external_nt_proxy_password></external_nt_proxy_password><external_nt_proxy_domain></external_nt_proxy_domain><external_nt_proxy_host></external_nt_proxy_host><anonymize>false</anonymize><terminate_proxies_on_completion>false</terminate_proxies_on_completion><number_of_required_proxies>5</number_of_required_proxies><originator_edition>2</originator_edition><logging_level>1</logging_level><date_exported>April 28, 2011 15:13:18</date_exported><character_set>UTF-8</character_set><scrapeable-files sequence="-1" will-be-invoked-manually="true" tidy-html="dont"><last-scraped-data></last-scraped-data><URL>http://planning.broxbourne.gov.uk/Planning/lg/GFPlanningSearchResults.page</URL><BASICAuthenticationUsername></BASICAuthenticationUsername><last-request></last-request><name>Broxbourne - Next Results Page</name><extractor-patterns sequence="2" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text><table id="_id71:results" summary="List of planning applications that meet the search criteria specified" title="List of planning applications">
<thead>
<tr><th>Reference Number</th><th>Location</th><th>Proposal</th><th>Valid Date</th></tr></thead>
<tbody id="_id71:results:tbody_element">
~@TABLEDATA@~</tbody></table>
</pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><regular-expression></regular-expression><identifier>TABLEDATA</identifier></extractor-pattern-tokens>
 
<script-instances><script-instances when-to-run="80" sequence="1" enabled="true"><script><script-text>String record = dataRecord.get("TABLEDATA");
session.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ :: ");
 
int recordsOnPage = Integer.parseInt(session.getVariable("NUMBER_MATCHES"));
 
if(record!= null) {
        String[] trData = record.split("<tr");
        session.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ :: " + trData.toString());
        if(trData != null && trData.length > 0) {
                int trCounter = trData.length - 1  ;
                session.log("Total records on the page :: "+trCounter);
                session.log("Total records read  :: "+ (recordsOnPage + trCounter));
                session.setVariable("NUMBER_MATCHES", String.valueOf(recordsOnPage + trCounter));
        }      
}
 
 
 
</script-text><name>Broxbourne - Records Counter Script</name><language>Interpreted Java</language></script></script-instances>
<owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name>
 
</script-instances>
</extractor-patterns><extractor-patterns sequence="1" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text><tr~@CLASS@~><td><!-- <t:outputText value="#{therow.fields['ref_no]}"/> --><input id="~@ID@~" name="~@NAME@~" type="submit" value="~@APPLICATION_NUMBER@~" onclick="__w2disableActions(this);;if(typeof window.clearFormHiddenParams__id71!='undefined'){clearFormHiddenParams__id71('_id71');}" onmousedown="this.className='linkButtondown';" onmouseup="this.className='linkButtonover';" onmouseover="this.className='linkButtonover';" onmouseout="this.className='linkButton';" onkeypress="__w2disableActions(this);" onkeydown="this.className='linkButtondown';" onkeyup="this.className='linkButtonover';" class="linkButton" onfocus="this.className='linkButtonover';" onblur="this.className='linkButton';" /></td><td>~@LOCATION@~</td><td>~@PROPOSAL@~</td><td>~@REGISTRATION_OR_VALIDATED_DATE@~</td></tr>
</pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="2"><regular-expression>[^"]*</regular-expression><identifier>ID</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="4"><regular-expression>[^"]*</regular-expression><identifier>APPLICATION_NUMBER</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="5"><identifier>LOCATION</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="7"><identifier>REGISTRATION_OR_VALIDATED_DATE</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="6"><identifier>PROPOSAL</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><identifier>CLASS</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="3"><regular-expression>[^"]*</regular-expression><identifier>NAME</identifier></extractor-pattern-tokens>
 
<script-instances><script-instances when-to-run="80" sequence="1" enabled="true"><script><script-text>
 
FileWriter out = null;
String councilName = null;
 
try
{
 
        // Set a variable in session to inform TITLE extraction pattern about pattern match.
        // Extractor pattern will inturn will use this to set the EXECUTION_STATUS to be propogated
        // back to the scheduler process.
        session.setVariable("PATTERN_MATCH_FOUND", "FOUND");
        session.log( "*#############   after pattern match found *########*");
        Date date = new Date();
        session.log( "System Date--------->" +date);
        import java.text.*;
        // Date fromatters
        session.log( "Applying Formatters--------->");
        java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
        java.text.SimpleDateFormat batchDateformatter = new java.text.SimpleDateFormat("ddMMyyyy");
        java.text.DateFormat apDateformatter = new java.text.SimpleDateFormat("dd MMM yyyy");
        session.log( "After Applying Formatters--------->");
        String today = formatter.format(date);
        session.log( "String Date--------->" +today);
        councilName = session.getVariable("COUNCIL_NAME");
        session.log( "COUNCIL NAME from session--------->" + councilName);
        councilName = councilName.replaceAll(" ","_");
        session.log( "COUNCIL NAME is--------->" + councilName);
        // Define a variable for batch number. In the script we will use date as batch number.
        // In real time scenario, this will be passed in by scheduler as a parameter.
          String batchNumber = batchDateformatter.format(date);
    DateFormat appFormatter;
          String dateObserve = today;
                Date dateToFormatForFile = new Date();
                appFormatter = new SimpleDateFormat("dd-MM-yyyy");
                dateToFormatForFile = appFormatter.parse(dateObserve);
        if(session.getVariable( "BATCH_NUMBER" ) !=null ) {
                batchNumber = session.getVariable( "BATCH_NUMBER" );
                session.log( "************************* BATCH NUMBER IS *************"+batchNumber);                   
        }
       
        // Default file path for windows environment. For Unix scheduler will pass it as a parameter and will be set as session variable.
                        String filePath  = "c:\\ABI\\";
        //String filePath  = "/export/home/ss/harvest/csv/screen-scraper/";
       
        if(session.getVariable( "FILE_PATH" ) !=null) {
                filePath = session.getVariable( "FILE_PATH" ); 
                session.log( "************************* FILE PATH IS *************"+filePath); 
        }
       
        if(session.getVariable( "PAGE_COUNTER" ) != null) {
                int pageCounter = Integer.parseInt((String)session.getVariable( "PAGE_COUNTER" )) ;
                pageCounter++; 
                session.log( "PAGE COUNTER IS ================================="+pageCounter );
                session.setVariable( "PAGE_COUNTER", pageCounter.toString());
        }
       
        String fileName = batchNumber+"-"+councilName+"-"+today+".txt";
        session.log( "The Council File Name is ------>"+fileName );
  session.setVariable("COUNCIL_FILE_NAME",fileName);
 
        // Open up the file to be appended to.
        out = new FileWriter( filePath+fileName, true );
       
        // CSV will consist of fiels in below format
        // BATCH_NUMBER,TODAY,APP_REG_DATE,APP_NUMBER,APP_STATUS,APP_URL
       
        out.write( "\"" + batchNumber + "\"~" );
        out.write( "\"" + apDateformatter.format(dateToFormatForFile) + "\"~" );
 
       
 
  //Try catch placed here to handle exception happened due to wrong date values.
        if(dataRecord.get( "DATE_RECEIVED" ) != null) {
 
                        DateFormat formatter ;
      Date dateToFormat;
                        try {    
                        String dateReceived = dataRecord.get( "DATE_RECEIVED" );
                        if(dateReceived.indexOf("/") != -1) {
                                dateReceived = dateReceived.replaceAll(" ","");
                        }
                        session.log("Inide Date =========================="+dateReceived);
                if(dateReceived.indexOf("/") != -1 && dateReceived.length()>10){  
         dateReceived = dateReceived.replaceAll("/"," ");
         dateToFormat = new Date(dateReceived);
         }
         else   if(dateReceived.indexOf("/") != -1) {
                  dateReceived = dateReceived.replaceAll(" ","");
                                dateToFormat = new Date();
                                formatter = new SimpleDateFormat("dd/MM/yyyy");
                                dateToFormat = formatter.parse(dateReceived);
                }else if(dateReceived.indexOf("-") != -1){
                                dateToFormat = new Date();
                                formatter = new SimpleDateFormat("dd-MM-yyyy");
                                dateToFormat = formatter.parse(dateReceived);
                }
                else {
                                     dateToFormat = new Date();
                                //formatter = new SimpleDateFormat("d MMM yyyy");
                                dateToFormat = apDateformatter.parse(dateReceived);
        }
                out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
                } catch (Exception e)
                                        {
                                          out.write( "\"" + "" + "\"~" );
                                                session.log("Exception :"+e);  
                                        }    
                        } else if(session.getVariable( "USE_FROMDATE_AS_RECEIVED_DATE" ).equals("true")){
                          String dateReceived = session.getVariable("FROMDATE");
                          dateToFormat = new Date();
                          formatter = new SimpleDateFormat("dd/MM/yyyy");
                          dateToFormat = formatter.parse(dateReceived);
                                out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
                } else {
                                out.write( "\"" + "" + "\"~" );
                }
       
 
        if(dataRecord.get( "REGISTRATION_OR_VALIDATED_DATE" ) != null){
 
        DateFormat formatter ;
        Date dateToFormat;
                 try {  
                    String dateValidated = dataRecord.get( "REGISTRATION_OR_VALIDATED_DATE" );
 
                   if(dateValidated.indexOf("/") != -1) {                  
                        dateValidated = dateValidated.replaceAll(" ","");
                    }
       
        if(dateValidated.indexOf("/") != -1 && dateValidated.length()>10){
        session.log("Inside Date Validated if block================================");
         //dateValidated = dateValidated.replaceAll(" ","");
         dateValidated = dateValidated.replaceAll("/"," ");
         dateToFormat = new Date(dateValidated);
         }
         else if(dateValidated.indexOf("/") != -1) {
         session.log("Inside Date Validated Else block==============================");
          dateValidated = dateValidated.replaceAll(" ","");
                        formatter = new SimpleDateFormat("dd/MM/yyyy");
                        dateToFormat = formatter.parse(dateValidated);
        } else if(dateValidated.indexOf("-") != -1){
                        //dateToFormat = new Date();
                                formatter = new SimpleDateFormat("dd-MM-yyyy");
                                dateToFormat = formatter.parse(dateValidated);
                }
                else {
                  //dateToFormat = new Date();                               
                                dateToFormat = apDateformatter.parse(dateValidated);
        }
       
                } catch (Exception e)
                {
                        session.log("Exception :"+e);
                        String dateValidated = session.getVariable("FROMDATE");
                        dateToFormat = new Date();
                        formatter = new SimpleDateFormat("dd/MM/yyyy");
                        dateToFormat = formatter.parse(dateValidated);         
                }  
 
                  out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
   
        }else if(session.getVariable( "USE_FROMDATE_AS_REG_OR_VALIDATION_DATE" ).equals("true") || dataRecord.get( "REGISTRATION_OR_VALIDATED_DATE" ) == null){
            String dateValidated = session.getVariable("FROMDATE");
                        dateToFormat = new Date();
                        formatter = new SimpleDateFormat("dd/MM/yyyy");
                        dateToFormat = formatter.parse(dateValidated);
                        out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
        }       /*else {
                        out.write( "\"" + "" + "\"~" );
        }*/
       
        if(dataRecord.get( "APPLICATION_NUMBER" ) != null){
                        out.write( "\"" + dataRecord.get( "APPLICATION_NUMBER" ) + "\"~" );
        }else {
                        out.write( "\"" + "" + "\"~" );
        }
        if(dataRecord.get( "APP_STATUS" ) != null) {
                out.write( "\"" + dataRecord.get( "APP_STATUS" ) + "\"~" );
        }
        else if(session.getVariable( "APP_STATUS" ) != null) {
                out.write( "\"" + session.getVariable( "APP_STATUS" ) + "\"~" );
        }else {
                out.write( "\"" + "" + "\"~" );
        }
       
        if(dataRecord.get( "APPLICATION_URL" ) != null ){
                String siteUrl = dataRecord.get( "APPLICATION_URL" );
                 // if the applicaiton URL is relative, append the baseURL stored in a separate parammeter by the executor script.
                 if(siteUrl.indexOf("http") == -1) {
                                siteUrl = session.getVariable( "SITE_BASE_URL" )+ siteUrl;
                 }
                 else {
                        siteUrl = dataRecord.get( "APPLICATION_URL" );
                 }
                out.write( "\"" + siteUrl.replaceAll("amp;","") + "\"~" );
        }else if(session.getVariable( "APPLICATION_URL" ) != null){
          String siteUrl = session.getVariable( "APPLICATION_URL" );
         // if the applicaiton URL is relative, append the baseURL stored in a separate parammeter by the executor script.
                 if(siteUrl.indexOf("http") == -1) {
                                siteUrl = session.getVariable( "SITE_BASE_URL" )+ siteUrl;
                 }
                 else {
                        siteUrl = dataRecord.get( "APPLICATION_URL" );
                 }
        out.write( "\"" + siteUrl.replaceAll("amp;","") + "\"~" );
        }
       
        else if(null !=  session.getVariable("SEARCH_URL") )
        {
                out.write( "\"" + session.getVariable("SEARCH_URL") + "\"~" );
        }
        else
        {
        out.write( "\"" + "Unable to Find the URL" + "\"~" );
        }
       
 
//Proposal/Description Entries will comes in below field.
        if(dataRecord.get( "PROPOSAL" ) != null) {
                out.write( "\"" + dataRecord.get( "PROPOSAL" ).replaceAll("&amp;","&")+ "\"");
        }else if(session.getVariable( "PROPOSAL" ) != null) {
                out.write( "\"" + session.getVariable( "PROPOSAL" ).replaceAll("&amp;","&") + "\"~" );
        }else {
                out.write( "\"" + ""+"\"" );
        }
       
        out.write( "\n" );
        // Close up the file.
        //out.close();
 
        // Increment records collected counter
        String recordsCollectedCounter = session.getVariable( "RECORDS_COLLECTED");
        session.log( "BEFORE recordsCollectedCounter " +recordsCollectedCounter );
        if(recordsCollectedCounter != null && !"".equals(recordsCollectedCounter.trim())) {
            session.setVariable("RECORDS_COLLECTED", String.valueOf(Integer.parseInt(recordsCollectedCounter) + 1));   
        }
        session.log( "AFTER recordsCollectedCounter " +session.getVariable( "RECORDS_COLLECTED") );
        }
 
catch( Exception e )
{
        //e.printStackTrace();
        session.log( "An error occurred while writing the data to a file: " + e );
        session.setVariable( "EXECUTION_STATUS", "FAILURE" );
        throw new RuntimeException("Error occured while writing records to CSV file for council" + councilName, e);
       
} finally {
        // Close open resource.
        if(out != null) {
                out.close();
        }
}</script-text><name>Write data to a file</name><language>Interpreted Java</language></script></script-instances>
<owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name>
 
</script-instances>
</extractor-patterns><HTTPParameters sequence="6"><key>_id71_SUBMIT</key><type>POST</type><value></value></HTTPParameters><HTTPParameters sequence="8"><key>_id71:scroll_2</key><type>POST</type><value>idx~#PAGECOUNTER#~</value></HTTPParameters><HTTPParameters sequence="2"><key>_id71:token</key><type>POST</type><value>~#TOKEN#~</value></HTTPParameters><HTTPParameters sequence="4"><key>_id71:_link_hidden_</key><type>POST</type><value></value></HTTPParameters><HTTPParameters sequence="1"><key>javax.faces.ViewState</key><type>POST</type><value>~#VIEWSTATE#~</value></HTTPParameters><HTTPParameters sequence="7"><key>_id71:scroll_1</key><type>POST</type><value></value></HTTPParameters><HTTPParameters sequence="3"><key>_id71_SUBMIT</key><type>POST</type><value>1</value></HTTPParameters><HTTPParameters sequence="5"><key>_id71:_idcl</key><type>POST</type><value>_id71:scroll_2idx~#PAGECOUNTER#~</value></HTTPParameters>
 
<script-instances><owner-type>ScrapeableFile</owner-type><owner-name>Broxbourne - Next Results Page</owner-name></script-instances>
</scrapeable-files><scrapeable-files sequence="2" will-be-invoked-manually="false" tidy-html="dont"><last-scraped-data></last-scraped-data><URL>http://planning.broxbourne.gov.uk/Planning/lg/GFPlanningSearch.page</URL><BASICAuthenticationUsername></BASICAuthenticationUsername><last-request></last-request><name>Broxbourne - Search Results Page</name><extractor-patterns sequence="2" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text><input id="_id71:token" name="_id71:token" type="hidden" value="~@TOKEN@~" /></pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="true" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><regular-expression>[^"]*</regular-expression><identifier>TOKEN</identifier></extractor-pattern-tokens>
 
<script-instances><owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name></script-instances>
</extractor-patterns><extractor-patterns sequence="4" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text><table id="_id71:results" summary="List of planning applications that meet the search criteria specified" title="List of planning applications">
<thead>
<tr><th>Reference Number</th><th>Location</th><th>Proposal</th><th>Valid Date</th></tr></thead>
<tbody id="_id71:results:tbody_element">
~@TABLEDATA@~</tbody></table>
</pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><identifier>TABLEDATA</identifier></extractor-pattern-tokens>
 
<script-instances><script-instances when-to-run="80" sequence="1" enabled="true"><script><script-text>String record = dataRecord.get("TABLEDATA");
session.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ :: ");
 
int recordsOnPage = Integer.parseInt(session.getVariable("NUMBER_MATCHES"));
 
if(record!= null) {
        String[] trData = record.split("<tr");
        session.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ :: " + trData.toString());
        if(trData != null && trData.length > 0) {
                int trCounter = trData.length - 1  ;
                session.log("Total records on the page :: "+trCounter);
                session.log("Total records read  :: "+ (recordsOnPage + trCounter));
                session.setVariable("NUMBER_MATCHES", String.valueOf(recordsOnPage + trCounter));
        }      
}
 
 
 
</script-text><name>Broxbourne - Records Counter Script</name><language>Interpreted Java</language></script></script-instances>
<owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name>
 
</script-instances>
</extractor-patterns><extractor-patterns sequence="1" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text><tr~@CLASS@~><td><!-- <t:outputText value="#{therow.fields['ref_no]}"/> --><input id="~@ID@~" name="~@NAME@~" type="submit" value="~@APPLICATION_NUMBER@~" onclick="__w2disableActions(this);;if(typeof window.clearFormHiddenParams__id71!='undefined'){clearFormHiddenParams__id71('_id71');}" onmousedown="this.className='linkButtondown';" onmouseup="this.className='linkButtonover';" onmouseover="this.className='linkButtonover';" onmouseout="this.className='linkButton';" onkeypress="__w2disableActions(this);" onkeydown="this.className='linkButtondown';" onkeyup="this.className='linkButtonover';" class="linkButton" onfocus="this.className='linkButtonover';" onblur="this.className='linkButton';" /></td><td>~@LOCATION@~</td><td>~@PROPOSAL@~</td><td>~@REGISTRATION_OR_VALIDATED_DATE@~</td></tr>
</pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="6"><identifier>PROPOSAL</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="3"><regular-expression>[^"]*</regular-expression><identifier>NAME</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><identifier>CLASS</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="7"><identifier>REGISTRATION_OR_VALIDATED_DATE</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="2"><regular-expression>[^"]*</regular-expression><identifier>ID</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="5"><identifier>LOCATION</identifier></extractor-pattern-tokens><extractor-pattern-tokens optional="false" save-in-session-variable="false" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="4"><regular-expression>[^"]*</regular-expression><identifier>APPLICATION_NUMBER</identifier></extractor-pattern-tokens>
 
<script-instances><script-instances when-to-run="80" sequence="1" enabled="true"><script><script-text>
 
FileWriter out = null;
String councilName = null;
 
try
{
 
        // Set a variable in session to inform TITLE extraction pattern about pattern match.
        // Extractor pattern will inturn will use this to set the EXECUTION_STATUS to be propogated
        // back to the scheduler process.
        session.setVariable("PATTERN_MATCH_FOUND", "FOUND");
        session.log( "*#############   after pattern match found *########*");
        Date date = new Date();
        session.log( "System Date--------->" +date);
        import java.text.*;
        // Date fromatters
        session.log( "Applying Formatters--------->");
        java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
        java.text.SimpleDateFormat batchDateformatter = new java.text.SimpleDateFormat("ddMMyyyy");
        java.text.DateFormat apDateformatter = new java.text.SimpleDateFormat("dd MMM yyyy");
        session.log( "After Applying Formatters--------->");
        String today = formatter.format(date);
        session.log( "String Date--------->" +today);
        councilName = session.getVariable("COUNCIL_NAME");
        session.log( "COUNCIL NAME from session--------->" + councilName);
        councilName = councilName.replaceAll(" ","_");
        session.log( "COUNCIL NAME is--------->" + councilName);
        // Define a variable for batch number. In the script we will use date as batch number.
        // In real time scenario, this will be passed in by scheduler as a parameter.
          String batchNumber = batchDateformatter.format(date);
    DateFormat appFormatter;
          String dateObserve = today;
                Date dateToFormatForFile = new Date();
                appFormatter = new SimpleDateFormat("dd-MM-yyyy");
                dateToFormatForFile = appFormatter.parse(dateObserve);
        if(session.getVariable( "BATCH_NUMBER" ) !=null ) {
                batchNumber = session.getVariable( "BATCH_NUMBER" );
                session.log( "************************* BATCH NUMBER IS *************"+batchNumber);                   
        }
       
        // Default file path for windows environment. For Unix scheduler will pass it as a parameter and will be set as session variable.
                        String filePath  = "c:\\ABI\\";
        //String filePath  = "/export/home/ss/harvest/csv/screen-scraper/";
       
        if(session.getVariable( "FILE_PATH" ) !=null) {
                filePath = session.getVariable( "FILE_PATH" ); 
                session.log( "************************* FILE PATH IS *************"+filePath); 
        }
       
        if(session.getVariable( "PAGE_COUNTER" ) != null) {
                int pageCounter = Integer.parseInt((String)session.getVariable( "PAGE_COUNTER" )) ;
                pageCounter++; 
                session.log( "PAGE COUNTER IS ================================="+pageCounter );
                session.setVariable( "PAGE_COUNTER", pageCounter.toString());
        }
       
        String fileName = batchNumber+"-"+councilName+"-"+today+".txt";
        session.log( "The Council File Name is ------>"+fileName );
  session.setVariable("COUNCIL_FILE_NAME",fileName);
 
        // Open up the file to be appended to.
        out = new FileWriter( filePath+fileName, true );
       
        // CSV will consist of fiels in below format
        // BATCH_NUMBER,TODAY,APP_REG_DATE,APP_NUMBER,APP_STATUS,APP_URL
       
        out.write( "\"" + batchNumber + "\"~" );
        out.write( "\"" + apDateformatter.format(dateToFormatForFile) + "\"~" );
 
       
 
  //Try catch placed here to handle exception happened due to wrong date values.
        if(dataRecord.get( "DATE_RECEIVED" ) != null) {
 
                        DateFormat formatter ;
      Date dateToFormat;
                        try {    
                        String dateReceived = dataRecord.get( "DATE_RECEIVED" );
                        if(dateReceived.indexOf("/") != -1) {
                                dateReceived = dateReceived.replaceAll(" ","");
                        }
                        session.log("Inide Date =========================="+dateReceived);
                if(dateReceived.indexOf("/") != -1 && dateReceived.length()>10){  
         dateReceived = dateReceived.replaceAll("/"," ");
         dateToFormat = new Date(dateReceived);
         }
         else   if(dateReceived.indexOf("/") != -1) {
                  dateReceived = dateReceived.replaceAll(" ","");
                                dateToFormat = new Date();
                                formatter = new SimpleDateFormat("dd/MM/yyyy");
                                dateToFormat = formatter.parse(dateReceived);
                }else if(dateReceived.indexOf("-") != -1){
                                dateToFormat = new Date();
                                formatter = new SimpleDateFormat("dd-MM-yyyy");
                                dateToFormat = formatter.parse(dateReceived);
                }
                else {
                                     dateToFormat = new Date();
                                //formatter = new SimpleDateFormat("d MMM yyyy");
                                dateToFormat = apDateformatter.parse(dateReceived);
        }
                out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
                } catch (Exception e)
                                        {
                                          out.write( "\"" + "" + "\"~" );
                                                session.log("Exception :"+e);  
                                        }    
                        } else if(session.getVariable( "USE_FROMDATE_AS_RECEIVED_DATE" ).equals("true")){
                          String dateReceived = session.getVariable("FROMDATE");
                          dateToFormat = new Date();
                          formatter = new SimpleDateFormat("dd/MM/yyyy");
                          dateToFormat = formatter.parse(dateReceived);
                                out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
                } else {
                                out.write( "\"" + "" + "\"~" );
                }
       
 
        if(dataRecord.get( "REGISTRATION_OR_VALIDATED_DATE" ) != null){
 
        DateFormat formatter ;
        Date dateToFormat;
                 try {  
                    String dateValidated = dataRecord.get( "REGISTRATION_OR_VALIDATED_DATE" );
 
                   if(dateValidated.indexOf("/") != -1) {                  
                        dateValidated = dateValidated.replaceAll(" ","");
                    }
       
        if(dateValidated.indexOf("/") != -1 && dateValidated.length()>10){
        session.log("Inside Date Validated if block================================");
         //dateValidated = dateValidated.replaceAll(" ","");
         dateValidated = dateValidated.replaceAll("/"," ");
         dateToFormat = new Date(dateValidated);
         }
         else if(dateValidated.indexOf("/") != -1) {
         session.log("Inside Date Validated Else block==============================");
          dateValidated = dateValidated.replaceAll(" ","");
                        formatter = new SimpleDateFormat("dd/MM/yyyy");
                        dateToFormat = formatter.parse(dateValidated);
        } else if(dateValidated.indexOf("-") != -1){
                        //dateToFormat = new Date();
                                formatter = new SimpleDateFormat("dd-MM-yyyy");
                                dateToFormat = formatter.parse(dateValidated);
                }
                else {
                  //dateToFormat = new Date();                               
                                dateToFormat = apDateformatter.parse(dateValidated);
        }
       
                } catch (Exception e)
                {
                        session.log("Exception :"+e);
                        String dateValidated = session.getVariable("FROMDATE");
                        dateToFormat = new Date();
                        formatter = new SimpleDateFormat("dd/MM/yyyy");
                        dateToFormat = formatter.parse(dateValidated);         
                }  
 
                  out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
   
        }else if(session.getVariable( "USE_FROMDATE_AS_REG_OR_VALIDATION_DATE" ).equals("true") || dataRecord.get( "REGISTRATION_OR_VALIDATED_DATE" ) == null){
            String dateValidated = session.getVariable("FROMDATE");
                        dateToFormat = new Date();
                        formatter = new SimpleDateFormat("dd/MM/yyyy");
                        dateToFormat = formatter.parse(dateValidated);
                        out.write( "\"" + apDateformatter.format(dateToFormat) + "\"~" );
        }       /*else {
                        out.write( "\"" + "" + "\"~" );
        }*/
       
        if(dataRecord.get( "APPLICATION_NUMBER" ) != null){
                        out.write( "\"" + dataRecord.get( "APPLICATION_NUMBER" ) + "\"~" );
        }else {
                        out.write( "\"" + "" + "\"~" );
        }
        if(dataRecord.get( "APP_STATUS" ) != null) {
                out.write( "\"" + dataRecord.get( "APP_STATUS" ) + "\"~" );
        }
        else if(session.getVariable( "APP_STATUS" ) != null) {
                out.write( "\"" + session.getVariable( "APP_STATUS" ) + "\"~" );
        }else {
                out.write( "\"" + "" + "\"~" );
        }
       
        if(dataRecord.get( "APPLICATION_URL" ) != null ){
                String siteUrl = dataRecord.get( "APPLICATION_URL" );
                 // if the applicaiton URL is relative, append the baseURL stored in a separate parammeter by the executor script.
                 if(siteUrl.indexOf("http") == -1) {
                                siteUrl = session.getVariable( "SITE_BASE_URL" )+ siteUrl;
                 }
                 else {
                        siteUrl = dataRecord.get( "APPLICATION_URL" );
                 }
                out.write( "\"" + siteUrl.replaceAll("amp;","") + "\"~" );

        }else if(session.getVariable( "APPLICATION_URL" ) != null){
          String siteUrl = session.getVariable( "APPLICATION_URL" );
         // if the applicaiton URL is relative, append the baseURL stored in a separate parammeter by the executor script.
                 if(siteUrl.indexOf("http") == -1) {
                                siteUrl = session.getVariable( "SITE_BASE_URL" )+ siteUrl;
                 }
                 else {
                        siteUrl = dataRecord.get( "APPLICATION_URL" );
                 }
        out.write( "\"" + siteUrl.replaceAll("amp;","") + "\"~" );
        }
       
        else if(null !=  session.getVariable("SEARCH_URL") )
        {
                out.write( "\"" + session.getVariable("SEARCH_URL") + "\"~" );
        }
        else
        {
        out.write( "\"" + "Unable to Find the URL" + "\"~" );
        }
       
 
//Proposal/Description Entries will comes in below field.
        if(dataRecord.get( "PROPOSAL" ) != null) {
                out.write( "\"" + dataRecord.get( "PROPOSAL" ).replaceAll("&amp;","&")+ "\"");
        }else if(session.getVariable( "PROPOSAL" ) != null) {
                out.write( "\"" + session.getVariable( "PROPOSAL" ).replaceAll("&amp;","&") + "\"~" );
        }else {
                out.write( "\"" + ""+"\"" );
        }
       
        out.write( "\n" );
        // Close up the file.
        //out.close();
 
        // Increment records collected counter
        String recordsCollectedCounter = session.getVariable( "RECORDS_COLLECTED");
        session.log( "BEFORE recordsCollectedCounter " +recordsCollectedCounter );
        if(recordsCollectedCounter != null && !"".equals(recordsCollectedCounter.trim())) {
            session.setVariable("RECORDS_COLLECTED", String.valueOf(Integer.parseInt(recordsCollectedCounter) + 1));   
        }
        session.log( "AFTER recordsCollectedCounter " +session.getVariable( "RECORDS_COLLECTED") );
        }
 
catch( Exception e )
{
        //e.printStackTrace();
        session.log( "An error occurred while writing the data to a file: " + e );
        session.setVariable( "EXECUTION_STATUS", "FAILURE" );
        throw new RuntimeException("Error occured while writing records to CSV file for council" + councilName, e);
       
} finally {
        // Close open resource.
        if(out != null) {
                out.close();
        }
}</script-text><name>Write data to a file</name><language>Interpreted Java</language></script></script-instances>
<owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name>
 
</script-instances>
</extractor-patterns><extractor-patterns sequence="3" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text> </div><table class="scroller"><tr><td><a href="#" onclick="return oamSubmitForm('_id71','_id71:scroll_2first',null,[['_id71_SUBMIT','1'],['_id71:scroll_2','first']]);" id="_id71:scroll_2first"><img src="/Planning/images/Navigation/ardbk.png" alt="First Page" /></a></td><td><a href="#" onclick="return oamSubmitForm('_id71','_id71:scroll_2previous',null,[['_id71_SUBMIT','1'],['_id71:scroll_2','previous']]);" id="_id71:scroll_2previous"><img src="/Planning/images/Navigation/arbk.png" alt="Previous Page" /></a></td>~@PAGES1@~<td><a href="#" onclick="return oamSubmitForm('_id71','_id71:scroll_2next',null,[['_id71_SUBMIT','1'],['_id71:scroll_2','next']]);" id="_id71:scroll_2next"><img src="/Planning/images/Navigation/arfwd.png" alt="Next Page" /></a></td><td><a href="#" onclick="return oamSubmitForm('_id71','_id71:scroll_2last',null,[['_id71_SUBMIT','1'],['_id71:scroll_2','last']]);" id="_id71:scroll_2last"><img src="/Planning/images/Navigation/ardfwd.png" alt="Last Page" /></a></td></tr></table><input type="hidden" name="_id71_SUBMIT" value="1" /><input type="hidden" name="_id71:_link_hidden_" /><input type="hidden" name="_id71:_idcl" /><input type="hidden" name="_id71_SUBMIT" /><input type="hidden" name="_id71:scroll_1" /><input type="hidden" name="_id71:scroll_2" />
</pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="true" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><regular-expression></regular-expression><identifier>PAGES1</identifier></extractor-pattern-tokens>
<script-instances><script-instances when-to-run="80" sequence="1" enabled="true"><script><script-text>String record = dataRecord.get("PAGES1");
session.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ :: ");
 
if(record!= null) {
        String[] tdData = record.split("<td");
        int tdCounter = 0;
        session.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ :: " + tdData.toString());
        if(tdData != null && tdData.length > 0) {
                session.log("Length " + tdData.length);
                tdCounter = tdData.length - 1;
               
                session.log("Total number of pages :: "+tdCounter);
                session.setVariable("TOTAL_PAGES", String.valueOf(tdCounter));
        }      
}</script-text><name>Broxbourne - Set Pagination Data For Loop Pages Script</name><language>Interpreted Java</language></script></script-instances>
<owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name>
</script-instances>
</extractor-patterns><HTTPParameters sequence="9"><key>_id68:valid_dateTo</key><type>POST</type><value>~#TODATE#~</value></HTTPParameters><HTTPParameters sequence="10"><key>_id68:proposal</key><type>POST</type><value></value></HTTPParameters><HTTPParameters sequence="5"><key>_id68:decision_dateTo</key><type>POST</type><value>dd/mm/yyyy</value></HTTPParameters><HTTPParameters sequence="11"><key>_id68:committee_dateFrom</key><type>POST</type><value>dd/mm/yyyy</value></HTTPParameters><HTTPParameters sequence="3"><key>_id68:application_address</key><type>POST</type><value></value></HTTPParameters><HTTPParameters sequence="6"><key>_id68:received_dateFrom</key><type>POST</type><value>dd/mm/yyyy</value></HTTPParameters><HTTPParameters sequence="12"><key>_id68:committee_dateTo</key><type>POST</type><value>dd/mm/yyyy</value></HTTPParameters><HTTPParameters sequence="4"><key>_id68:decision_dateFrom</key><type>POST</type><value>dd/mm/yyyy</value></HTTPParameters><HTTPParameters sequence="8"><key>_id68:valid_dateFrom</key><type>POST</type><value>~#FROMDATE#~</value></HTTPParameters><HTTPParameters sequence="2"><key>_id68:ref_no</key><type>POST</type><value></value></HTTPParameters><HTTPParameters sequence="14"><key>_id68_SUBMIT</key><type>POST</type><value>1</value></HTTPParameters><HTTPParameters sequence="13"><key>_id68:_id87</key><type>POST</type><value>Search</value></HTTPParameters><HTTPParameters sequence="1"><key>javax.faces.ViewState</key><type>POST</type><value>~#VIEWSTATE#~</value></HTTPParameters><HTTPParameters sequence="7"><key>_id68:received_dateTo</key><type>POST</type><value>dd/mm/yyyy</value></HTTPParameters><HTTPParameters sequence="15"><key>_id68:_idcl</key><type>POST</type><value></value></HTTPParameters><HTTPParameters sequence="16"><key>_id68:_link_hidden_</key><type>POST</type><value></value></HTTPParameters>
<script-instances><script-instances when-to-run="30" sequence="1" enabled="true"><script><script-text>session.setCookie("planning.broxbourne.gov.uk", "jsessionid", session.getVariable("JSESSIONID"));</script-text><name>Broxbourne - Set Cookie </name><language>Interpreted Java</language></script></script-instances><script-instances when-to-run="40" sequence="2" enabled="true"><script><script-text>int pageCounter = 2;
if( session.getVariable( "TOTAL_PAGES" ) != null){
        int totalNumberOfPages = Integer.parseInt(session.getVariable( "TOTAL_PAGES" ));
        for(i=1; i < totalNumberOfPages; i++) {
 
        session.setVariable("PAGECOUNTER", pageCounter);
        session.setVariable("TOKEN",session.getVariable("TOKEN"));
        session.scrapeFile("Broxbourne - Next Results Page");
        pageCounter = pageCounter + 1;
        }
}
 
// Check exit condition
 
int totalNumberOfRecords = Integer.parseInt(session.getVariable( "NUMBER_MATCHES"));;
String numberMatches = session.getVariable( "NUMBER_MATCHES");
String recordsCollectedCounter = session.getVariable( "RECORDS_COLLECTED");
if(numberMatches.equalsIgnoreCase("One")) {
            totalNumberOfRecords = 1;
}else{
 totalNumberOfRecords = Integer.parseInt(numberMatches);
}
 
session.log("**************recordsCollectedCounter *******" + recordsCollectedCounter);
session.log("**************totalNumberOfRecords ******* " + totalNumberOfRecords);
 
if(recordsCollectedCounter != null
      && !"".equals(recordsCollectedCounter.trim())
      && Integer.parseInt(recordsCollectedCounter) == totalNumberOfRecords) {
      session.setVariable( "EXECUTION_STATUS", "SUCCESS" );
      session.log("**************EXECUTION_STATUS ******* SUCCESS");
}else{
      session.setVariable("SESSION_STATUS_CODE","RECORDS_MISMATCHED");
}
 
session.log("**************SESSION_STATUS_CODE *******" + session.getVariable("SESSION_STATUS_CODE"));
</script-text><name>Broxbourne - Loop For Pages Script</name><language>Interpreted Java</language></script></script-instances>
<owner-type>ScrapeableFile</owner-type><owner-name>Broxbourne - Search Results Page</owner-name>
 
</script-instances>
</scrapeable-files><scrapeable-files sequence="1" will-be-invoked-manually="false" tidy-html="dont"><last-scraped-data></last-scraped-data><URL>http://planning.broxbourne.gov.uk/Planning/lg/plansearch.page</URL><BASICAuthenticationUsername></BASICAuthenticationUsername><last-request></last-request><name>Broxbourne - Landing Page</name><extractor-patterns sequence="2" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text>Set-Cookie: JSESSIONID=~@JSESSIONID@~; Path=/Planning</pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="true" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><regular-expression></regular-expression><identifier>JSESSIONID</identifier></extractor-pattern-tokens>
 
<script-instances><owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name></script-instances>
</extractor-patterns><extractor-patterns sequence="1" automatically-save-in-session-variable="false" if-saved-in-session-variable="0" filter-duplicates="false" cache-data-set="false" will-be-invoked-manually="false">
<pattern-text><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="~@VIEWSTATE@~" /></pattern-text><identifier>Untitled Extractor Pattern</identifier><extractor-pattern-tokens optional="false" save-in-session-variable="true" compound-key="true" strip-html="false" resolve-relative-url="false" replace-html-entities="false" trim-white-space="false" exclude-from-data="false" null-session-variable="false" sequence="1"><regular-expression>[^"]*</regular-expression><identifier>VIEWSTATE</identifier></extractor-pattern-tokens>
<script-instances><owner-type>ExtractorPattern</owner-type><owner-name>Untitled Extractor Pattern</owner-name></script-instances>
</extractor-patterns><HTTPParameters sequence="2"><key>Param</key><type>GET</type><value>lg.Planning</value></HTTPParameters><HTTPParameters sequence="1"><key>org.apache.shale.dialog.DIALOG_NAME</key><type>GET</type><value>gfplanningsearch</value></HTTPParameters>
<script-instances><script-instances when-to-run="30" sequence="1" enabled="true"><script><script-text>//session.clearCookies();
 
if(session.getVariable( "FROMDATE") == null){
        session.setVariable( "FROMDATE", "01/04/2011" );
}
 
if(session.getVariable( "TODATE") == null){
        session.setVariable( "TODATE", "12/04/2011" );
}
 
if(session.getVariable( "COUNCIL_NAME") == null){
        session.setVariable( "COUNCIL_NAME", "Broxbourne" );
}      
 
if(session.getVariable( "PAGE_COUNTER") == null){
        session.setVariable( "PAGE_COUNTER", "0");
}
 
if(session.getVariable( "SITE_BASE_URL") == null){
        session.setVariable( "SITE_BASE_URL", "http://planning.broxbourne.gov.uk/Planning/");
}
 
session.setVariable( "RECORDS_COLLECTED", "0" );
session.setVariable( "EXECUTION_STATUS", "FAILURE" );
 
session.setVariable("NUMBER_MATCHES", "0");
 
session.setVariable( "USE_FROMDATE_AS_REG_OR_VALIDATION_DATE", "true" );
session.setVariable( "USE_FROMDATE_AS_RECEIVED_DATE", "false" );
 
session.setVariable("FROM_DAYS_MAP",new java.util.HashMap());
session.setVariable("TO_DAYS_MAP",new java.util.HashMap());
 
session.setVariable( "SESSION_STATUS_CODE","RECORDS_MATCHED");
 
 
</script-text><name>Broxbourne - Init Script</name><language>Interpreted Java</language></script></script-instances>
<owner-type>ScrapeableFile</owner-type><owner-name>Broxbourne - Landing Page</owner-name>
 
</script-instances>
</scrapeable-files></scraping-session>

The response is as follows:
 
HTTP/1.1 200 OK
Cache-Control: no-store
Proxy-Connection: close
Date: Thu, 28 Apr 2011 09:40:06 GMT
X-Cache: MISS from netserv.ainproxy.arrkgroup.com
Cache-Control: no-cache
Pragma: no-cache
Cache-Control: max-age=0
Content-Language: en-GB
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Cache-Control: must-revalidate
Expires: Thu, 01 Jan 1970 00:00:00 GMT
 

Please suggest.

diptirmaya, Your scraping

diptirmaya,

Your scraping session got munged when you copy and pasted it into your message. Could I please have you email it to me instead?

scottw [@] screen-scraper

Thanks,
Scott

The session send by Email

Hi Scott,
i have send the session on your mail id.
Thanks.

diptirmaya, Well, this was an

diptirmaya,

Well, this was an elusive one for a minute. The solution ended up being to clear your cookies prior to manually setting the one jsession cookie.

Modify your Set Cookies script to look like the following.

session.clearCookies();
session.setCookie("planning.broxbourne.gov.uk", "jsessionid", session.getVariable("JSESSIONID"));

Let me know if that works for you.

-Scott