I am having a basic problem in running
servlets. I installed JSDK2.1 and wrote a basic servlet.
The code is from Suns' website. When i run the servlet by entering the name as
http://localhost:8080/basic It gives an error - "file not found."
I also modified the servlet.properties file to add my servlet as:
basic.code=SimpleServlet
Where SimpleServlet is my servlet class.
I ran the Servlet server currently and am able to successfully run one of the example servlet in the servlet.properties file.
I am missing something basic here. Can anyone help me.
Thanks.
-Hemanth
import javax.servlet.*;
import javax.servlet.http.*;
public class SimpleServlet extends HttpServlet
{
/**
* Handle the HTTP GET method by building a simple web page.
*/
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriterout;
Stringtitle = "Simple Servlet Output";
// set content type and other response header fields first
response.setContentType("text/html");
// then write the data of the response
out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println(title);
out.println("</TITLE></HEAD><BODY>");
out.println("<H1>" + title + "</H1>");
out.println("<P>This is output from SimpleServlet.");
out.println("</BODY></HTML>");
out.close();
}
}