tags:

views:

385

answers:

7

Hi All,

How to create DHTML pages using C language? Please give me some web site where I can find the step by step procedure to create DHTML pages using C.

Regards, NM

+3  A: 

C? Not so suitable language for that.

But, someone did CMS with that, called Tokyopromenade, Opensource

http://1978th.net/tokyopromenade/

Just for your information

S.Mark
+3  A: 

For using C to generate (D|X)HTML, you will have to write CGI programs. CGI programs should output the Content-type: text/html or equivalent before HTML is output.

After that, you can upload the program to the cgi-bin/ or equivalent directory. Remember to set the execution bit on the file.

Alan Haggai Alavi
+1  A: 

Have your C program write Content-type: text/html\n\n to stdout before anything else, and you can then generate whatever HTML you wish. The empty line is critical!

mmsmatt
Can you please give me some link where I can find some examples.
Malar
+4  A: 

Assuming your application will be executed as a CGI of apache or another HTTP server, you only need to print the HTTP headers and the content of the page to stdout.

The minimal headers expected are:

Content-type: text/html\r\n\r\n

(do not forget the double \r\n)

then write your page.

eyalm
The line should end with a \r\n.
Vijay Mathew
+1  A: 

"DHTML" is mostly used to describe client-side functionality, and you use Javascript for that.

But if you mean dynamic web pages (server-side functionality), and you must use C, you can use CGI (Common Gateway Interface, RFC3875):

http://hoohoo.ncsa.illinois.edu/cgi/primer.html

However, using C for web pages is not a good choice. It would be better to use a scripting language like Python or Ruby, and either study the CGI support in that language or go for a framework like Ruby on Rails.

kek
C could be much faster than Python or Ruby.
Kinopiko
Not using CGI -- CGI is super slow, super high overhead for each request.
Conrad Meyer
@Conrad: CGI isn't super slow or super high overhead. The overhead comes from the startup of the scripting languages.
Kinopiko
A: 

To create dynamic webpages using C, there are a couple of ways you can go about this (this is not an exhaustive list):

  1. You use CGI, an old standard for creating dynamic webpages. The way this works is that for each request to your site, your webserver creates a new process, invokes your program (passing information about the request to your program using environmental variables and stdin), and feeds the output from your program to the web browser. As other replies have noted, CGI requires your program to specify the HTTP response headers to the browser.

  2. If you're interesting in using C for performance reasons when developing webpages (this is sort of diving into insanity), CGI clearly isn't an option. If you're this much of a masochist, you should probably look into linking with FastCGI or creating an Apache module. In fact, since you like pain this much, you might as well just start with thttpd and insert your code where needed.

Good luck. You might also consider seeing a shrink.

Conrad Meyer
A: 

Search "C library for web applications" here on stackoverflow, it has some good answers.

I haven't tried it, maybe someone would find it usefull: klone. It is a framework for building standalone web serververs and html templating with embedded C.