After compiling the servlet program when i put the class file in ROOT/WEB-INF/classes folder...and through internet explorer by using url http://localhost:8080/servlet/Demo error shows sourse not found...
but when i put the class file in examples/WEB-INF/classes folder and by editing the web.xml file(describing the servlet name and mapping) program runned....but by changing the ROOT/WEB-INF/web.xml file similarly error shows...
but when i put the class file in examples/WEB-INF/classes folder and by editing the web.xml file(describing the servlet name and mapping) program runned....but by changing the ROOT/WEB-INF/web.xml file similarly error shows...
Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class Demo extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
Enumeration hnames = req.getHeaderNames();
out.println("<H3> The request headers are: </H3>");
while (hnames.hasMoreElements())
{
String hname = (String)hnames.nextElement();
Enumeration hvalues = req.getHeaders(hname);
out.println("<BR>");
if (hvalues != null) ;
{
while (hvalues.hasMoreElements())
{
String hvalue = (String)hvalues.nextElement();
out.println(hname + ":" + hvalue);
}
}
}
}
}
Comment