Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Popup displays HTML source, not expected web page

by LaidBackWebSage (Acolyte)
on Oct 02, 2003 at 19:49 UTC ( #296056=perlquestion: print w/ replies, xml ) Need Help??
LaidBackWebSage has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, oh, purveyors of Perl Wisdom... I have a link in a CGI-generated page that creates a popup when clicked on to provide the user with some specific information. Instead of receiving the web page, I get the HTML source code. (The Perl variables interpolate correctly.) The problem only occurs in Mozilla & Netscape. The code uses very simple code:
print "Content-type: text/html\n\n"; print " <html><head> <title>Title Goes Here</title><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no +-cache\"> <style type=text/css> <!-- .bodydef { font-family: Verdana, Arial, Helvetica, sans-serif; font-s +ize: 9pt; color: #000000; line-height: normal; list-style-type: disc}H4 { + font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; c +olor: #000000; line-height: normal; list-style-type: disc}--></style> </head> <body onload=\"self.focus();\"> <div align=left class=bodydef> <h4>Test Page</h4> The total cost of \$$HASH{foo} includes a \$$HASH{bar} Fee and + a \$2 Assistance Fee per person. <br><br> </body> </html>";
I suspect it is something to do with the HTTP HEADER construction... Thoughts? Thanks! Kevin J.

Comment on Popup displays HTML source, not expected web page
Download Code
Re: Popup displays HTML source, not expected web page
by jdtoronto (Prior) on Oct 02, 2003 at 20:35 UTC
    Updated oops! wrong, sorry :)

    But now I got it right! Um, why does it work when I add a shebang line to the top? On Linux/Apache server, Mozilla browser. Look at it here:

    http://www.thanksforthereply.com/cgi-bin/tp.cgi

    #!/usr/bin/perl print "Content-type: text/html\n\n"; print " <html><head> <title>Title Goes Here</title><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no +-cache\"> <style type=text/css> <!-- .bodydef { font-family: Verdana, Arial, Helvetica, sans-serif; font-s +ize: 9pt; color: #000000; line-height: normal; list-style-type: disc}H4 { + font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; c +olor: #000000; line-height: normal; list-style-type: disc}--></style> </head> <body onload=\"self.focus();\"> <div align=left class=bodydef> <h4>Test Page</h4> The total cost of \$$HASH{foo} includes a \$$HASH{bar} Fee and + a \$2 Assistance Fee per person. <br><br> </body> </html>";
    jdtoronto
      Um, maybe i missed something, but isn't print "Content-type: text/html\n\n"; the header he needs (which he has in his post that you say is missing)?
        Yep! My mistake, I corected it :) The shebang is what is actually missing.

        jdtoronto

      All,

      Significant detail I forgot to mention: mod_perl.

      I will accept my floggings without rancor. :-)

      JD's link works; but when I copy the code from his reply on our server, I still get the source code when I click the link.

      I'm starting to get a little paranoid...

      Thanks, all.

      Kevin J
Re: Popup displays HTML source, not expected web page
by tcf22 (Priest) on Oct 02, 2003 at 20:50 UTC
    Is this all that your script contains? My first guess would be that you may have excluded some code before this, and that code is throwing out some sort of warning, which is messing up the headers. Everything that you posted looks correct and print "Content-type: text/html\n\n"; should be all the headers that you need.

    If there is anymore info that you could give, I could probably give you a better answer.

    - Tom

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://296056]
Approved by Aristotle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-07-31 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (245 votes), past polls