/**

* @author  Reghu
* @version 1.0
*
* Development Environment        :  JDeveloper 2.0
* Name of the Application        :  HelloWorld.java
* Creation/Modification History  :

*
* Overview of the application    :
*
* This application describes how to create a basic servlet application. The
* Servlet application creates a simple HTML page and displays
* "Hello Oracle World" string in it.
*

*/

import java.io.*;

// Packages for Servlets
import javax.servlet.*;
import javax.servlet.http.*;


public class HelloWorld extends HttpServlet {

  /**
  * Initializes the servlet. The method is called once, automatically, by the
  * Java Web Server when it loads the servlet. The init() method should save
  * ServletConfig object so that it can be returned by the getServletConfig()
  * method.
  */
  public void init(ServletConfig config) throws ServletException {

    super.init(config);
  }

  /**
  * Method to process HTTP GET requests. In this method a Simple HTML page
  * displaying "Hello Oracle World" is built and presented to user.
  * The parameters of doGet() method is
  * 1) HttpServletRequest object, which encapsulates the data from the client
  * 2) HttpServletResponse object, which encapsulates the response to the client
  **/

  public void doGet(HttpServletRequest p_req, HttpServletResponse p_res)
                                        throws ServletException, IOException {

    // Sets the content type of the response
    p_res.setContentType("text/html");

    // Create a ServletOutputStream to write the output
    ServletOutputStream l_out = p_res.getOutputStream();

    // Use ServletOutputStream to print the Hello Oracle World String in
    // the HTML page

    l_out.println("<HTML><HEAD><TITLE>Hello Oracle World</TITLE></HEAD>");
    l_out.println("<BODY BGCOLOR =\"lightgrey\"><CENTER><BR><BR>");
    l_out.println("<TABLE BORDER=4 BGCOLOR =\"blue\">");
    l_out.println("<TR><TD align =\"center\" valign=\"center\" >");
    l_out.println("<FONT face=\"Arial,helvetica\" color =red size=5>");
    l_out.println("&nbsp; Hello Oracle World &nbsp;</FONT></TD></TR></TABLE>");
    l_out.println("</BODY></HTML>");

    l_out.close(); // Close the ServletOutputStream
  }

  /**

  * Override the getServletInfo() method which is supposed to return information
  * about the Servlet, e.g. the servlet name, version, author and copyright
  * notice. This is not required for the function of the HelloWorld servlet but
  * can provide valuable information to the user of a servlet who sees the
  * returned text in the administration tool of the Web Server.
  **/
  public String getServletInfo() {
    return "Hello World servlet 1.0 by Reghu";
  }

  /**
  * Destroy the servlet. This method is called once when the servlet is unloaded
  **/

  public void destroy() {
     super.destroy();
  }
}
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy