Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: CGI::Application header problem

by trwww (Priest)
on Dec 28, 2010 at 01:35 UTC ( #879357=note: print w/replies, xml ) Need Help??

in reply to CGI::Application header problem

This works fine for me:

$ cat #!/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 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" ""> <html xmlns="" 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://879357]
[erix]: 1=0 is as short as TOP :)
[erix]: "code of someone that died" -- kinda nice if your code stops working too
[erix]: hard to implement, hmm
[Corion]: erix: Well, they also seem to have changed the server, or some software, or whatever, and seem to be in the process of changing the DB schema from having the "username" as primary key to something else.
[Corion]: Far too many things being done at once, or maybe only now has it become apparent that nobody knows that piece of software anymore
[marto]: good morning all
[Corion]: I consider having an abstract key as userid in your system good, because the "real" company-wide (or even larger) user id will likely not fit your criteria well

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2017-01-23 09:35 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (192 votes). Check out past polls.