This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Oracle CLOBs and JSP?  RSS feed

 
Jim Vlachos
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm storing HTML pages as CLOBs in an Oracle database. I want to get a page(as a CLOB) and have my JSP page write out the HTML from the CLOB so that the browser sees the output from the JSP as an HTML page. The problem I'm having is getting JSP to output a CLOB instead of a string, or to find some way of getting the entire CLOB represented as a string for output.

My JSP page consists entirely of the following:

<%@ page import="CMRDocSQL" %>
<%! CMRDocSQL docGetter = new CMRDocSQL(); %>
<%= docGetter.selectCMRDoc(request.getParameter("selDocName")) %>

CMRDocSQL is just the object that defines the selectCMRDoc() method. That method includes the follwing code to find the doc by name in the Oracle table and extract the HTML from the DOCHTML column. The DOCHTML column is of type CLOB:

ResultSet rs = stmt.executeQuery("SELECT DOCHTML from CMR_DOCS where DOCNAME = '" + pDocName + "'");

if (rs.next()){
returnDoc = ((OracleResultSet)rs).getCLOB("DOCHTML");
returnString = returnDoc.getSubString(1, 15000);
}

I can use getSubString() to retrieve part of the CLOB (as above) and have selectCMRDoc() return it as a String. What I can't do is get selectCMRDoc() to return the entire content of the CLOB, i.e. to allow my JSP page to present the entire HTML page by writing the entire CLOB to the browser.

Is anyone able to shed any light on a solution, or do you know of anywhere I could go (on the internet, or perhaps a book) to find out how to do what I'm trying to do? I'd appreciate any assistance.
 
prabhat kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you can do iswithout writing html code in the jsp page
u retrieve the CLOB
then set the content type to text/html
and write the CLOB to
ServletOutputStream.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!