Perl outputs html instead of xml on new server  (Cache-Control: no-store, no-cache, must-revalidate)

Posted on 2009-05-07
Last Modified: 2012-05-06
I have attached output of on both servers, script causing problems and the correct output on old server and also the html output on new server.

 This is only differerence I can see on new server  is this line beside the OS and 64bit and LWP : v5.803  on old and  LWP : v5.805 on new

is this line of perl test
"& /etc/httpd"

What is the remedy???
see attached perl scripts, output generated on both servers and the output of on both servers
 this is the extra code that is produced in perl output on new server
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Type: text/xml; charset=ISO-8859-1 "

Open in new window
Question by:webguy62
  • 7
  • 7
LVL 39

Expert Comment

ID: 24329661
What version of the CGI module are you using on both servers?  What webserver are you using on both servers?

The extra text isn't part of the XML, it's part of the HTTP protocol.

Author Comment

ID: 24330049

Operating system Centos 5  

Perl : v5.008008
httpd 2.2.3-11.el5_2.centos.4  
mod_perl 2.0.2-6.3.el5  
mysql 5.0.45-7.el5  


OS Fedora
httpd 2.0.54-10.4  
mod_perl 2.0.1-1.fc4  
mysql 4.1.20-1.FC4.1  
Perl : v5.008006
LVL 39

Expert Comment

ID: 24330592
Check the CGI module version with this (notice the use of single and double qoutes... you should cut/paste to get it exactly):
    perl -MCGI -e 'print "$CGI::VERSION\n"'
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.


Author Comment

ID: 24330883
new 3.15
old 3.10

I have fuidn some changes in apache 2.2 vs 2.0  but none that wil affect this script?
LVL 39

Expert Comment

ID: 24332905
How did you generate the files in the zip file?  The gsur_pl.txt script does not appear to have generated any of the attached files.
LVL 39

Expert Comment

ID: 24333009
It appears that you are using $USERID to manage a session.  If this is the case, you should consider using the CGI::Session module, which makes session management very easy.

Also, you might want to consider using one of the template modules designed for HTML.

Author Comment

ID: 24333135
thje gsur_pl.txt generates  this xml which is good - <markers>
  <results count="3" longitude="-75.953813333333" latitude="39.800456333333" />
  <marker i="0" lat="39.803396" lng="-75.955323" id="5486136" price="1,200.0" city="OXFORD" property_type="Commercial" beds="" baths="OneBath" address="247 REEDVILLE" ph="1" />
  <marker i="1" lat="39.800474" lng="-75.954889" id="5483128" price="375,000.0" city="OXFORD" property_type="Commercial" beds="" baths="" address="1895 BALTIMORE" ph="0" />
  <marker i="2" lat="39.797499" lng="-75.951228" id="5332915" price="1,900,000.0" city="OXFORD" property_type="Commercial" beds="" baths="" address="355 REEDVILLE" ph="10" />

but on new server with newer verions of apache it adds this text at the top of output  

Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Type: text/xml; charset=ISO-8859-1
LVL 39

Expert Comment

ID: 24336694
The gsur_pl.txt from your zip file doesn't generate that XML, it generates an html page.

Author Comment

ID: 24337046
exacty and this is the problem. but on our old server it did genrate an xml page.     What do we need to do to change ti so it generates an xml on new server?

 see example links of 2 different servers exectuing same script.    We found that when "RewriteEngine on" is on in htaccess the perl script gives error of access denied. when rewrite rule is set to off we dont get  access denied error. but the output of the perl file is not proper, the file headers are not correct.
like in the link below. This file gives html output instead of xml.
The same code on old server gives the out put as XML file, like in the link below.whiich is what we need
We tried to make the rewrite rule and perl script work together but still the output is not proper.

below is rewrite rule for new server
RewriteCond %{REQUEST_URI} !^\/?(js|scripts|wysiwyg|design_demo|midas|map|api).*$

RewriteCond %{REQUEST_URI} !^\/?(map|api|admin).*$
RewriteRule   ^([0-9A-Za-z\_-]*)/([0-9A-Za-z\ \_-]*)/?$ index.php?pageid=$1&value=$2 [NS,QSA,L,PT] [E=UID:$1]
RewriteCond %{REQUEST_URI} !^\/?(map|api|admin).*$
RewriteRule   ^([0-9A-Za-z\_\/-]*)(/|\.html|/index\.html|/index\.htm)?$ index.php?pageid=$1 [NS,QSA,L,PT] [E=UID:$1]

Author Comment

ID: 24337136
In other words this same gsur_pl.txt gives us different out put on 2 different servers. WE need it to give us  xml resutls on new server :)  the new server has newer version of apache and cgi as noted in past remarks.  I could not find anything in apache changes that would cause this
LVL 39

Expert Comment

ID: 24338973
attach your index.php file.

Author Comment

ID: 24339146
below is index.php and I think I know where you are going with this so I inclulded the config file as an upload

# File Name: includes/index.php    
# Index file for the user site, this will render full view of the site







      $pageId = $_REQUEST['pageid'];
      $pageId = '2';

/*---------------------------Load master data------------------------------*/

$hdlMasterData = new clsMasterData($hdlDb,$pageId);
$pageType = $hdlMasterData->arrSiteMasterData['pageType'];

/*---------------------------Built current page------------------------------*/
$hdlCurrentPage = new clsCurrentPage($hdlDb, $pageId, $hdlMasterData->arrSiteMasterData);

/*---------------------------Built panels ------------------------------*/
$hdlBuildPanels = new clsBuildPanels($hdlDb, $pageId);

/*---------------------------Built header ------------------------------*/
$hdlBuildHeader = new clsBuildHeader($hdlDb,$pageId);

/*---------------------------Built Footer ------------------------------*/

/*---------------------------Built Template ------------------------------*/
#$hdlSitePanels['left'] = $hdlBuildPanels->fnGeneratePanels("left");
#$hdlSitePanels['right'] = $hdlBuildPanels->fnGeneratePanels("right");  

$hdlDisplaySite = new clsDisplaySite($hdlDb,$hdlCurrentPage->strPageContent,

/*---------------------------Display Template ------------------------------*/

print $hdlDisplaySite->showHTML;

LVL 39

Accepted Solution

Adam314 earned 500 total points
ID: 24339336

header('Content-type: text/xml');   #New line
print $hdlDisplaySite->showHTML;    #existing line

Open in new window


Author Closing Comment

ID: 31579115
it works  thanks big time...

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert grep lines to perl 6 79
Post xml via PHP Soap Client 3 72
How to configure empty element in XML Document parser? 15 44
How to implement an additional command 16 45
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question