tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Cleenewerck" <Thomas.Cleenewe...@cs.kuleuven.ac.be>
Subject Internal Servlet Error: IllegalStateException
Date Mon, 25 Sep 2000 09:54:55 GMT
Hello,

I'm trying to acces a oracle database from a jsp-page.  Every works as long as I do not use
use a seperate object to establish my database connection.  I'm getting the following error:
Error: 500
Location: /thomas/jspper.jsp
Internal Servlet Error:

java.lang.IllegalStateException: Response has already been committed
	at org.apache.tomcat.core.HttpServletResponseFacade.sendError(HttpServletResponseFacade.java:157)
	at org.apache.jasper.runtime.JspServlet.unknownException(JspServlet.java:299)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:377)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:156)
	at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
	at java.lang.Thread.run(Unknown Source)

Actualy the code for making a connection, i want to reuse....  This a bad example of reuse,
but it is just for testing !!!
say the class TempData:

import java.sql.*;
import Database.*;
public class TempData  {

 public void perform() {
 try {
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
 } catch (java.sql.SQLException SqlExc) {
      //throw(new RegisterDriverException("Error while registering the JDBC driver\nReceived:
"+SqlExc.toString()));
 }
  
 String $connectString = "xxxxxxxxxxx";
 String $username="xxxxxxxx";
 String $password="xxxxxxxxx";
 try {
        Connection $connection = DriverManager.getConnection ($connectString,$username,$password);
   
 } catch (java.sql.SQLException SqlExc) {
      //throw(new ConnectionException("Error while opening database connection\nReceived:
"+SqlExc.toString()));
 }
 } }


and the code off my jsp page will no look like this:

<%@ page import="java.util.*, Database.*, java.sql.*" %>
<html>
<body>
<h1> joehoe </h1>
<%
 TempData td = new TempData();
  td.perform();
%>
</body>
</html>



What works:
<%@ page import="java.util.*, Database.*, java.sql.*" %>
<html>
<body>
<h1> joehoe </h1>
<%

try {
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
 } catch (java.sql.SQLException SqlExc) {
      //throw(new RegisterDriverException("Error while registering the JDBC driver\nReceived:"+SqlExc.toString()));
 }
    
 String $connectString = "xxxxx";
 String $username="xxxx";
 String $password="xxxxx";
 try {
        Connection $connection = DriverManager.getConnection ($connectString,$username,$password);
   
 } catch (java.sql.SQLException SqlExc) {
      //throw(new ConnectionException("Error while opening database connection\nReceived:
"+SqlExc.toString()));
  }
%>
</body>
</html>

Mime
View raw message