to the main page about the tutorial  INTERACTIVE WEB SERVICES WITH JAVA back up next

HelloWorld

Variants of a well-known program:

"Hello World" in JSP:
<html><head><title>JSP</title></head>
<body><h1>Hello World!</h1>
This page was last updated: <%= new java.util.Date() %>
</body></html>

"Hello World" in Servlets:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet 
{
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html><head><title>Servlet</title></head>");
        out.println("<body><h1>Hello World!</h1>");
        out.println("This page was last updated: " + new java.util.Date());
        out.println("</body></html>");
    }
}

"Hello World" in JWIG:
import dk.brics.jwig.runtime.*;

public class Hello extends Service 
{
    public class Example extends Session 
    {
        public void main() {
            XML x = [[ <html><head><title>JWIG</title></head><body>
                       <h1><[what]></h1></body></html> ]];
            x = x <[ what = [[ Hello World! ]] ];
            show x;
        }
    }
}

Note that: