home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / asp / response.asp < prev    next >
Encoding:
Text File  |  2003-09-03  |  2.8 KB  |  126 lines

  1. #!/usr/bin/perl /usr/bin/asp-perl
  2.  
  3. <!--#include file=header.inc-->
  4.  
  5. <% 
  6.     my $form = $Request->QueryString();
  7.  
  8.     # Expires
  9.     $form->{expires} ||= 0;
  10.     $Response->{Expires} = $form->{expires};
  11.     my $update_time = &Apache::ASP::Date::time2str(time()+$form->{expires});
  12.  
  13.     # Buffer
  14.     (defined $Session->{buffer}) 
  15.         || ($Session->{buffer} = $Response->{Buffer});
  16.     if($form->{buffer}) {
  17.         $Session->{buffer} = ! $Session->{buffer};
  18.     }
  19.     my $buffer_display = $Session->{buffer} 
  20.         ? "Set Buffer Off" : "Set Buffer On";
  21.     $Response->{Buffer} = $Session->{buffer};
  22.  
  23.     # Cookie
  24.     if($form->{cookie_name}) {
  25.         $Response->{Cookies}{$form->{cookie_name}} = 
  26.             $form->{cookie_value};
  27.     }
  28. %>
  29.  
  30. <center>
  31. <table border=1 cellpadding=2>
  32. <tr><td colspan=2 align=center><b>Response Object Demonstration</b></td></tr>
  33. <form action=<%=$demo->{file}%> method=GET>
  34. <tr>
  35.     <td colspan=2 align=center>
  36.     <input type=submit name=buffer value="<%=$buffer_display%>">
  37.     <input type=submit name=clear value="Clear Test">
  38.     <input type=submit name=submit value="Submit">
  39.     <td>
  40. </tr>
  41. <tr>
  42.     <td><b>Input Text</b></td>
  43.     <td><input type=text name=text value="<%=$form->{text}%>"></td>
  44. </tr>
  45. <tr>
  46.     <td><b>Expires In (secs)</b></td>
  47.     <td><input type=text name=expires value="<%=$form->{expires}%>"></td>
  48. <% if($update_time) { %>
  49. <tr>
  50.     <td><b>Expires On</b></td>
  51.     <td><%=$update_time%></td>
  52. </tr>
  53. <% } %>
  54. <tr>
  55.     <td><b>Buffering</b></td>
  56.     <td><%=$Response->{Buffer} ? "On" : "Off"%></td>
  57. </tr>
  58. <tr>
  59.     <td><b>Cookie (Name=Value)</b></td>
  60.     <td>
  61.         <input type=text name=cookie_name 
  62.             value="<%=$form->{cookie_name}%>">
  63.         =
  64.         <input type=text name=cookie_value
  65.             value="<%=$form->{cookie_value}%>">
  66.     </td>
  67. </tr>
  68. <tr>
  69.     <td><b>Cookies*</b></td>
  70.     <td>
  71.     <%
  72.     while(my($k, $v) = each %{$Request->Cookies()}) {
  73.         if(ref $v) {
  74.             print "$k:<br>\n";
  75.             for(keys %$v) {
  76.                 print "- $v->{$_}=$_<br>\n";
  77.             }                
  78.         } else {
  79.             print "$k=$v\n";
  80.         }
  81.         print "<p>\n";
  82.     }
  83.     %>
  84.     </td>
  85. </tr>
  86.  
  87. <tr>
  88.     <td><b>Clear Demo</b></td>
  89.     <td>
  90.     <% 
  91.     # printing now aliases to $Response->Write()
  92.     print "
  93.         Here's some text that was added to the box... 
  94.         if you pressed clear and buffering is on,
  95.         you will not see it...
  96.         ";
  97.  
  98.     # demo of $Response->Clear();
  99.     $Response->Flush(); 
  100.     %>
  101.     <!-- inserted text -->
  102.     <table border=1><tr><td>Input Text:<%=$form->{text}%></td></tr></table>
  103.     <%
  104.     if($form->{clear}) {
  105.         $Response->Clear();
  106.     }
  107.     %>
  108.     </td>
  109. </tr>
  110. <tr>
  111.     <td><b>print() demo</b></td>
  112.     <td>
  113.     <% print " perl print() now works! <P>\n"; %>        
  114.     </td>
  115. </tr>
  116.  
  117. </form>
  118. </table>
  119. </center>
  120. <p>
  121. * Please note that the cookie example takes 2 submits to show up
  122. in the table after setting it because the first time, the header
  123. is sent to the browser, and the 2nd, the browser sends it back.
  124.  
  125. <!--#include file=footer.inc-->
  126.