X
Xarky
Hi,
I have just downloaded and installed Tomcat 5.0.30. I entered on
the link localhost:8080 and followed some links and examples provided
over there. The worked fine.
Now I would like to create my own servlets. Just to start off I am
trying a hello world program(I know that this is available). I am
trying the following code.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class MyHelloWorld extends HttpServlet
{
public void init(ServletConfig c)
{
(c.getServletContext()).log("HelloWorld servlet initialized");
} // end method init
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println ("<html>");
out.println ("<head>");
out.println ("<title>" + "My title" + "</title>");
out.println ("</head>");
out.println ("<body bgcolor=\"white\">");
out.println ("Hello World !!!!");
out.println("</body>");
out.println ("</html>");
} // end method doGet
} // end class MyHelloWorld
I saved this program with .java extension and compiled it succesfully.
Now what should I do to have access to it on my web browser.
Thanks in Advance
I have just downloaded and installed Tomcat 5.0.30. I entered on
the link localhost:8080 and followed some links and examples provided
over there. The worked fine.
Now I would like to create my own servlets. Just to start off I am
trying a hello world program(I know that this is available). I am
trying the following code.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class MyHelloWorld extends HttpServlet
{
public void init(ServletConfig c)
{
(c.getServletContext()).log("HelloWorld servlet initialized");
} // end method init
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println ("<html>");
out.println ("<head>");
out.println ("<title>" + "My title" + "</title>");
out.println ("</head>");
out.println ("<body bgcolor=\"white\">");
out.println ("Hello World !!!!");
out.println("</body>");
out.println ("</html>");
} // end method doGet
} // end class MyHelloWorld
I saved this program with .java extension and compiled it succesfully.
Now what should I do to have access to it on my web browser.
Thanks in Advance