Servlets and JDBC

From: Xarky (bernardpace_at_yahoo.com)
Date: 12/11/04


Date: 11 Dec 2004 05:45:33 -0800


>> System.err.println(e);
>> e.printStackTrace();
>> System.exit(16);

> You shouldn't use System.exit in a Servlet. You don't want to bring the
> server down for every error.

The System.exit was removed and now my tomcat is not disconnecting.

>> When DB class is run from console mode, with the same query, it
works
>> perfect. When applied to servlet, the servlet is failing at the
>> Connection stage and my Tomcat is being disconnected. Why?

> Possible different permissions if tomcat runs as a service.

Also, after having removed the system.exit part, my programs seems to
connect and now it is failing in the try catch part. Error being
returned in web browser is the follwoing.

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

java.lang.NullPointerException
        ListBooksServlet.doGet(ListBooksServlet.java:42)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        filters.ExampleFilter.doFilter(ExampleFilter.java:101)

note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.30 logs.

--------------------------------------------------------------------------------

Apache Tomcat/5.0.30

>> Another question... in the database class when an error occurs in
the
>> catch statement, in console mode is displayed easily. How can this
be
>> done in servlets.

> Catch exceptions at the highest level (class ListBookServlet) and format
> the backtrace into HTML so that you can see it in the browser.

Can you give me a simple example of what you mean because I can't
understand it.



Relevant Pages

  • Re: Java Webservices - newbie question.....
    ... why would people use it on top of apache http server, ... Apache HTTPD in front of Tomcat is not needed but sometimes ... So, does that mean, java ws is a servlet itself? ...
    (comp.lang.java.programmer)
  • Re: Java Webservices - newbie question.....
    ... why would people use it on top of apache http server, ... Apache HTTPD in front of Tomcat is not needed but sometimes ... Say, i developed a few web services, which are some basic arithmetic ... Tomcat (or another servlet container) ...
    (comp.lang.java.programmer)
  • Re: servlet server ? (help)
    ... Tomcat is pretty much the standard. ... J2EE server. ... >> servers) for servlet based programming. ...
    (comp.lang.java.help)
  • Re: Advice on web app
    ... receive data and store it into a database. ... The best thing for a server application would be to start-up with Tomcat, ... should it be a http servlet? ...
    (comp.lang.java.programmer)
  • Re: Create Image on Unix
    ... > I'd like to create an image on a Unix server and save it to file. ... Why not create a servlet that writes image to the client directly? ... > Unix, Tomcat or Java environment? ...
    (comp.lang.java.programmer)