Solved

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

Posted on 1997-06-05
3
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

724 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