2 Replies Latest reply on May 21, 2005 5:14 AM by Maha AL-Menieir

    the HelloWorld servlet

    Maha AL-Menieir Newbie

      i have been trying to figure out if what i am doing is correct or not.
      i run the server from here:

      the server is running correctly, no errors. everything is fine. no errors with classpath or anything....

      then i open
      working fine also

      i go to the command line and i compile the servlet
      javac sallamServlet.java


      now, what do i do to run the servlet?
      i went to IE and typed down
      not working....

      this is the path:

      1) .project
      <?xml version="1.0" encoding="UTF-8"?>


      2) sallamServlet.java
      package deploy.FirstServlet;
      import java.io.IOException;
      import java.io.PrintWriter;
      import javax.servlet.ServletConfig;
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;

      /** This servlet Says Sallam to the user in a HTML page. */

      public class sallamServlet extends HttpServlet {
      * This method will be called by the Servlet Container when
      * this servlet is being placed into service.
      * @param config - the ServletConfig object that
      * contains configutation information for this servlet.

      public void init(ServletConfig config) {
      System.out.println("sallamServlet: init()");

      * This method handles the HTTP GET requests for this servlet.
      * It says Sallam to the user in an HTML page.
      * @param request - object that contains the request the
      * client has made of the servlet.
      * @param response - object that contains the response the servlet
      * sends to the client.
      * @exception java.io.IOException - if an input or output error is
      * detected when the servlet handles the GET request.
      * @exception ServletException - if the GET request could not be handled.

      public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

      // write the response to be displayed
      // set the response type

      // obtain the writer to write the response
      PrintWriter out = response.getWriter();

      // write the page title
      out.println("Servlet Example - Sallam");

      // write sallam

      // close the page

      // close the writer

      /** This method will be called by the Servlet Container when this servlet
      ** is being taken out of service.
      public void destroy() {
      System.out.println("sallamServlet: destroy()");

      }//Class sallamServlet

      3) sallamServlet.class
      was created when i compiled the java file

      4) sallam.html >> not sure why i wrote this one :s