Oct 042009
A “hello world” program has become the traditional first program that many people learn. Here’s i’ll show you how to print “Hello World” in A web page.
Using HTML
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>
Hello World
</TITLE>
</HEAD>
<BODY>
<P>hello world</P>
</BODY>
</HTML>
Using C cgi
#include <stdio.h>
int main(void) {
printf("Content-Type: text/plain;charset=us-ascii\n\n");
printf("Hello world\n\n");
return 0;
}
Using PHP
<?php
Print "Hello, World!";
?>
Using PERL
#!/usr/bin/perl print "Content-type: text/html\n\n"; print "Hello World.\n";
Using Python
#!/usr/bin/python print 'Content-Type: text/plain' print '' print 'Hello, world!'
Using javascript
<script type="text/javascript">
document.write('<b>Hello World</b>');
</script>
Using Java servlet
package test;
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class HelloServlet extends HttpServlet {
public void doGet (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
PrintWriter out = res.getWriter();
out.println("Hello, world!");
out.close();
}
}
Using JSP
<%@ page contentType="text/html;charset=WINDOWS-1252"%>
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<P>
<B>
<% out.println(" Hello World"); %> !
</B>
</P>
</BODY>
</HTML>
Using ASP
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<P>
<B>
<% Response.Write("Hello World!") %>
</B>
</P>
</BODY>
</HTML>
Using BASH
#!/bin/bash echo -e "Content-type: text/html\n" STR="Hello World!" echo $STR
And many more Language that i don’t know yet..
You may also want to read these posts:
- Querying Visitor IP address
- Sending HTML mail via sendmail cli
- Nginx, fastcgi, ‘Hello World’ in C
- real world unix/linux FIND usage
- Nginx, Strip All Newlines Using nginx-nonewlines Module
- Sort an integer array, What language do you use?
- The Large Hadron Collider: End of the world, or God’s own particle?
- Show GeoIP Badge On Your Website Using PHP And JavaScript
- Build Nginx RPM With ngx_cache_purge module
Follow me on Twitter