Solved

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

Posted on 1997-06-05
3
181 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
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 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 …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

740 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