Deploying servlet class file from webapp/ROOT/WEB-INF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Reshu Agarwal
    New Member
    • Jul 2010
    • 6

    Deploying servlet class file from webapp/ROOT/WEB-INF

    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...

    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);
    				}
    			}
    
    		}
    	}
    }
  • iohos
    Banned
    New Member
    • Jul 2010
    • 45

    #2
    corroborate wid d following dynamic servelet

    Code:
    import java.io.*;    
    import javax.servlet.*;    
    import javax.servlet.http.*;    
    import java.util.Date;    
       
    public class Time extends HttpServlet {    
     public void doGet(HttpServletRequest req, HttpServletResponse rsp)    
                   throws ServletException, IOException {    
       rsp.setContentType("text/html");    
       PrintWriter out = rsp.getWriter();    
       
       Date now = new Date(); // The current date/time    
       
       out.println("<html>");    
       out.println("<head><title> Time Check </title></head>");    
       out.println("<body>");    
       out.println("<p>The time is: " + now + "</p>");    
       out.println("</body></html>");    
     }    
    }
    u r making errors in variable defining
    Last edited by Niheel; Jul 28 '10, 04:37 PM. Reason: added code tags to code :)

    Comment

    Working...