Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This works fine for me:

$ cat cgiapp.pl #!/usr/local/bin/perl use warnings; use strict; TestApp->new->run; package TestApp; use base qw|CGI::Application|; use CGI::Application::Plugin::AutoRunmode; use CGI::Application::Plugin::Session; sub default : StartRunmode { my $self = shift; my $output; # get current access count my $access_count = $self->session->param('access_count') || 0; # increment access count $access_count++; # store new access count in session $self->session->param(access_count => $access_count); # get CGI object out of application my $q = $self->query; #build output $output = $q->start_html( -head => $q->meta({ -http_equiv => 'Content-Type', -content => 'text/html; charset=UTF-8' }), -title => 'access count application' ); $output .= $q->div("accessed $access_count time(s) this session"); $output .= $q->div(' '); $output .= $q->div( $q->a( {-href => $q->self_url} => 'access again' + ) ); $output .= $q->end_html; # set charset $self->header_add( -type => "text/html; charset=UTF-8"); # give output to app to send to user return( $output ); } $ perl cgiapp.pl Set-Cookie: CGISESSID=357a2d9c8f6ec5830c08beb44d12afb2; path=/ Date: Tue, 28 Dec 2010 01:31:47 GMT Content-Type: text/html; charset=UTF-8 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>access count application</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <div>accessed 1 time(s) this session</div><div> </div><div><a href="ht +tp://localhost">access again</a></div> </body> </html>

I'm sure if you run the code on the server, perhaps in the debugger, the cause of the problem will quickly jump out at you.


In reply to Re: CGI::Application header problem by trwww
in thread CGI::Application header problem by morgon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-20 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found