Solved

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

Posted on 1997-06-05
3
171 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now