The moose likes Servlets and the fly likes JSP vs. Servlet via JDBC-ODBC bridge Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP vs. Servlet via JDBC-ODBC bridge" Watch "JSP vs. Servlet via JDBC-ODBC bridge" New topic

JSP vs. Servlet via JDBC-ODBC bridge

Brett Paul

Joined: Oct 18, 2000
Posts: 2
Environment is a Win95 machine running jswdk101, jdk122.
Right before I started learning about JSP pages, etc., I had written a _servlet_ that would take information from an http post, and look up something in a database, then spit that data out to the response as html. That worked well, except that when garbagecollect would run, it would crash my server. Well, I went back and cleared out references to SQL-specific objects at the end of the routine, and lo and behold, it worked.
Then, I took that servlet and turned it into a JSP page. Same code, same clearing of the references, etc., but it again crashes my server.
Any ideas on what may be happening?
- Brett
Bhupinder Dhillon
Ranch Hand

Joined: Oct 12, 2000
Posts: 124
Make sure you are explicitly closing all the ResultSet and Statement objects and of course Connection too.
Brett Paul

Joined: Oct 18, 2000
Posts: 2
Yes, I am doing these things in both cases (servlet and jsp). However, like I said, it works fine (without crashing) in the servlet, but crashes the server in the JSP page. I might add that the output is sent back to the client first, and the crash happens on garbagecollect.
Paul Wetzel
Ranch Hand

Joined: Nov 02, 1999
Posts: 107
Are you using to declare your connection object and such, in your page. If so it means that vars declared in these blocks are available to all threads of the jsp and the next time you access the page that var (like a Connection object) has been close or set to null.
good luck
[This message has been edited by Paul Wetzel (edited October 18, 2000).]
I agree. Here's the link:
subject: JSP vs. Servlet via JDBC-ODBC bridge
It's not a secret anymore!