Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

Web Programming

I cannot figure out where errors messages would be contained.

My servlet compiles.  I put my class in web-inf classes folder.  I modified web.xml.  Nothing displays on the screen.  I'm using tomcat 5.5, eclipse 3.1.1 and jre/jdk 1.5.0_06.  I know that I do not need an xml file.  I am using http://java.sun.com/dtd/web-app_2_3.dtd because when I paste this into the browser IE does not complain.  I checked the log directory nothing is there nor in the Eclipse console.
0
latimercm4
Asked:
latimercm4
  • 2
1 Solution
 
jagadeesh_motamarriCommented:
but some debug statements and try....so that u can know if there is any problem at some part of the code...(when u say everything seems to be correct)
0
 
WelkinMazeCommented:
Hi,
You can execute the problem code and if you think that a logfile with error messages has to exist after this point you can make a search of the file system for files newer than the time of execution.
0
 
latimercm4Author Commented:
Here's my source code:

package org.eclipse.Ch11_02;

import java.io.*;import javax.servlet.*;
import javax.servlet.http.*;


public class ClassServlet extends HttpServlet{
      
      public void doGet(HttpServletRequest request,
                                     HttpServletResponse response)
                  throws IOException, ServletException{
                  try {
                        response.setContentType("text/html");
                        PrintWriter out = response.getWriter();
                        
                        out.println("<HTML>");
                        out.println("<HEAD>");
                        out.println("<TITLE>");
                        out.println("Sample Servlet");
                        out.println("</TITLE>");
                        out.println("</HEAD>");
                        out.println("<BODY>");
                        out.println("<H1>");
                        out.println("Sample Servlet");
                        out.println("</H1>");
                        out.println("This servlet is functional.");
                        out.println("</BODY>");
                        out.println("</HTML>");
                        
                  }catch (Exception e){
                        log("ClassServlet The following exception occured: " + e);
                        e.printStackTrace();
                  }catch (Error e) {
                        log("ClassServlet The following Error occurred:" +e);
                        e.printStackTrace();
                  }
      }      
}
0
 
WelkinMazeCommented:
You may put some  System.out.println("AAAAAAAAAAAAAAA");  statements in the catch clauses to see if your program gets there. If it is then such statements "AAAAAAAAAAAAAAA" will be printed in the Tomcat's console.

Your code seems fine to me at a first glance so maybe there is no errors to be logged so no error log files a re produced.

Also you may consider to replace the following two catch clauses

               }catch (Exception e){
                    log("ClassServlet The following exception occured: " + e);
                    e.printStackTrace();
               }catch (Error e) {
                    log("ClassServlet The following Error occurred:" +e);
                    e.printStackTrace();
               }

just with this one:

               }catch (Throwable e) {
                    log("ClassServlet The following Error occurred:" +e);
                    e.printStackTrace();
               }

It will cover the above two ones.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now