Solved

Loading an existing html file into a browser

Posted on 1998-07-01
7
150 Views
Last Modified: 2013-12-25
How can I load an existing HTML file into a browser from within a C cgi script? I 'm currently creating the HTML file on the fly but I want to create it only once and put it in a directory and then force the browser to reference it..
0
Comment
Question by:barlav
[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
7 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1830390
print "Content-type: text/html\r\n\r\n";

read html file and write the whole file to stdout


0
 
LVL 84

Expert Comment

by:ozo
ID: 1830391
Or, to force the browser to reference it

print "Location: http://some.machine/some.directory/some.doc\r\n\r\n";
0
 

Author Comment

by:barlav
ID: 1830392
I don't want to write a file out to stdout when it's already in existence. I want to force the browser to reference it. ozo's comment is close to the answer that I'm looking for but it doesn't work. I tried your answer ozo but it just creates a webpage that displays literally  "Location: http://some.machine/some.directory/some.doc\r\n\r\n" and not the html document that resides there.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

Author Comment

by:barlav
ID: 1830393
ozo,
  Your answer worked when I didn't set the MIME type ahead of time. Since you headed me in the right direction I'll be happy to award you the points if you submit your comment as an answer.
0
 

Expert Comment

by:chuckie_worm
ID: 1830394
That is one way of doing this, alternatively you could try the following.

  print "Content-type: text/html\n\n";              # HTTP header
  print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
  print "window.location.replace = '**URL**'\n";
  print "</SCRIPT>\n";

where **URL** is the URL of the page that you want to display.

Chuckie
0
 

Author Comment

by:barlav
ID: 1830395
It seems that the way I'm doing it now is much easier. Thanks for your answer chuckie_worm but I think it's only fair that I give the points to ozo since he put me in the right direction.
0
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
ID: 1830396
Location: http://some.machine/some.directory/some.doc

  or
Refresh: 0; URL=http://some.machine/some.directory/some.doc
Content-type: text/html

  or
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><meta http-equiv="refresh" content="0; url=http://some.machine/some.directory/some.doc">
</HEAD><BODY></BODY></HTML>
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

738 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