Hello,
I have recently started learning Servlets.Till now I wrote the code on Notepad and executed the
servlet on Sun Server. Today, I wrote the code on NetBeans. The servlet is running successfully but is not giving the correct output.
I created an application by name Servlet1.Under it, i created the servlet, FirstServlet in pack1 package by right clicking the Web Pages folder.
my code was as follows:
public class FirstServlet extends HttpServlet
{
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("Om Namah Shivaya");
} finally {
out.close();
}
}
I did not edit the HTML document in index.jsp.
The output therefore was Hello World!
So what is the use of println() method. why is not my object being called.
I thought the web.xml automatically modifies the HTML document based on the servlet code.
Thanks in advance,
Regards
Komal
[ October 13, 2008: Message edited by: Komal Amaresh ]