Hello,

I am trying to retrieve a CLOB field from an Oracle Database using a JSP
page and a Java Bean. I get the following error:


Location: /examples/jsp/helloracle/helloart.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.http.HttpConnectionHandler.processConnection
(HttpConnectionHandler.java:160)


at org.apache.tomcat.service.TcpConnectionThread.run


(SimpleTcpEndpoint.java:338) at java.lang.Thread.run(Unknown Source)


Below is my JSP code and my BEAN code:


JSP CODE:


<%@ page import="oracle.sql.*" %>


<%@ page import="java.sql.*" %>


<%@ page import = "helloracle.HelloOracleBeanClob" %>


<jsp:useBean id="brandnewline" class="helloracle.HelloOracleBeanClob">


<%


Connection connection = null;


Statement statement = null;


ResultSet results = null;


brandnewline.setTestvar();


try{


Class.forName("oracle.jdbc.driver.OracleDriver");


String url = "jdbc:oracle:thin:@ipaddress:port:dbname";


String query = "SELECT SERIES_SEQ FROM SSDEV.POL_ARTICLE WHERE SLUG = 'this
is the article for CIO'";


connection = DriverManager.getConnection(url,"userid","password");
statement = connection.createStatement();


results = statement.executeQuery(query);


if(results.next()) {


Clob localclob = results.getClob("CONTENT_XML");


long len = localclob.length();


String clobstring = localclob.getSubString(1,(int)len);


brandnewline.setXML(clobstring);


brandnewline.setSerieseq(results.getString("SERIES_SEQ"));


}


connection.close();


}


catch (ClassNotFoundException e) {


System.err.println("Could not load database driver!");


}


catch (SQLException e) {


System.err.println("Could not connect to the database!");


}


finally{


try { if (connection != null) connection.close(); }


catch (SQLException e) {}


}

%>
</jsp:useBean>
<html>
<body>
<table>
<TR>
<TD>Stuff:
<jsp:getProperty name="brandnewline" property="testvar"/></TD> <TD>
</TD>
</TR>
<TR>
<TD>SERIES SEQ:
<jsp:getProperty name="brandnewline" property="serieseq"/></TD> <TD>
</TD>
</TR>
<TR>
<TD>XML:
<jsp:getProperty name="brandnewline" property="XML"/></TD> <TD>
</TD>
</TR>
</table>
</body>
</html>

BEAN CODE:

package helloracle;

import java.util.*;

public class HelloOracleBeanClob {

private String passed_clob;
private String passed_series_seq;
private String test_var;

public void setXML(String myclob) {

passed_clob = myclob;

}

public void setSerieseq(String myseries_seq) {

passed_series_seq = myseries_seq;

}


public void setTestvar() {

test_var = "blahblah";

}


public String getXML() {

return passed_clob;
}

public String getSerieseq() {

return passed_series_seq;
}

public String getTestvar() {

return test_var;
}


}


Does anyone know what I'm doing wrong? Any help would be greatly
appreciated.

Thanks,

John Pallozzi
Web Engineer
ITworld.com, Inc.
Phone: (508) 303-9747
Fax: (508) 303-9753
[EMAIL PROTECTED]

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to