Solved

Why the HREF does not display the current contents of a file

Posted on 1997-06-05
3
175 Views
Last Modified: 2013-12-25
Dear CGI experts,

My perl script create HTML codes that contain an Hypertext link to a text file. If I append some items to the file, run the script again, and click on the Hypertext link then I can only see the previous version of the file. The only way to display the current version of the file is to use a 'Reload' botton of a WWW browser. I understand my perl script creates only an HREF link, not contents of the file, so I think clicking on the HREF should always display the current contents of the file. I am using Netscape Navigator V 3.01 and my perl script is using the 'POST' method  as a 'request method'.
My perl script was written as follows. Thanks in advance.

-----------------------------------------
#!/usr/local/bin/perl
print "Content-type: text/html", "\n\n";
$request_method = $ENV{'REQUEST_METHOD'};

if ($request_method eq "GET") {
    $form_info = $ENV{'QUERY_STRING'};
}
else {
    $size_of_form_information = $ENV{'CONTENT_LENGTH'};
     read (STDIN, $form_info, $size_of_form_information);
}
.
.
.
print<<"print_tag";
....
<A HREF="http://www.lan.ac.uk/~user9/files/log_$comp_id.txt">View the contents of a file</A>   <BR>
....
print_tag
-----------------------------------------------------
Note that $comp_id is a variable where the value of a parameter is stored.
0
Comment
Question by:dcs0ock
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
icd earned 20 total points
ID: 1828179
I had a similar problem with gif images that were generated on the fly. You can change the code to:-

<A HREF="http://www.lan.ac.uk/~user9/files/log_$comp_id.txt?$foo">View the contents of a file</A><BR>

Where $foo is a new number each time the page is modified. You could either increment a counter or use the current time of day.
This will fool the browser into thinking it is a different URL each time even though the GET parameter is not used.
0
 

Author Comment

by:dcs0ock
ID: 1828180
Dear ICD,

Thank you very much for your excellent answer. It works ok now.
But most of end users probably don't realise that they have to rerun(reload) a specific perl script in order to get the current file information. Is there any other way to get the current information without rerunning the perl script whenever end
users click on an HREF link?
Many thanks.
0
 
LVL 5

Expert Comment

by:icd
ID: 1828181
Well, there are techniques to reload a document periodically although I am not very familiar with them. Client pull and server push.

Client pull means the client periodically re-requests the document.
Server push means the server sends the document whenever it changes.

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
need a quick help to fix the script logic 4 69
Choosing the right PHP framework for web develpment 8 103
Need help to rewrite script 3 79
exchange ,script 10 41
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

786 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