Link to home
Start Free TrialLog in
Avatar of vadlamudikumar
vadlamudikumar

asked on

Displaying the Data in JSP from servlet

Hi,
    Iam kind of stuck in middle of something, Iam trying to get the data from servlet, and the data is stored in Vector in the servlet and Iam trying to display it in the JSP, and Everytime I do it, Iam getting this error called

java.io.IOException: "Error: Attempt to clear a buffer that's already been flushed"

Here is the snap shot of the code where I think the error is occuring, Iam sure something is wrong with the little java code in JSP

Could anybody help me in resovling this, I would gretaly apprectaie the help
Thanks in advance
shiv

<% java.util.Enumeration enum = auditListVector.elements();
        out.println(auditListVector.size());
         rox.darsaudit.VewAuditList vewAuditList = new rox.darsaudit.VewAuditList();
        while(enum.hasMoreElements()) {
           
           vewAuditList = (VewAuditList) enum.nextElement();
             
              %>
     

             
     <TR>
     
      <td><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"> <%=vewAuditList.getStatus() %></td>
      <td align="center"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><%=vewAuditList.getWebtitle() %></td>
      <td align="center"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"> <%=vewAuditList.getLastmoddate() %> </td>
     
      <td align="center"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"> <%=vewAuditList.getJobid() %></td>
       
    </TR>
    <% } %>
Avatar of vemul
vemul

I don't think it has anything to do with the code.. it is to be with the include and forward directive locations, guess u should have the forward before the include tag

check this out...

http://forum.java.sun.com/thread.jsp?thread=298196&forum=45&message=1181769

vemul
Avatar of vadlamudikumar

ASKER

Hi Vemul,
                 It make sense what u said, but I don't have any forard Tag in my JSP, all I have is one include tag, I guess my question is Can anybody tell me the possible reasons for getting the "java.io.IOException: "Error: Attempt to clear a buffer that's already been flushed"

kind of error,
Thanks in advance
shiv
can u show us the complete jsp code or atleast the heading portion of the jsp page
Hi Vemul,
        This is the  JSP,   Iam using
Thanks
shiv





<%@ page errorPage="RoxDefaultErrorReporter.jsp" %>
<jsp:useBean id="vewHFBean" scope="session" class="rox.common.VewHFBean"/>
<jsp:useBean id="Message" scope="request" class="java.lang.String"/>
<jsp:useBean id="auditListVector" scope="request" class="java.util.Vector"/>
<jsp:useBean id="vewAuditList" scope="request" class="rox.darsaudit.VewAuditList" />


<HTML>
<HEAD>
<META http-equiv="Content-Style-Type" content="text/css">
<META name="GENERATOR" content="IBM WebSphere Page Designer V3.5 for Windows">
<TITLE>ROX = Raider Online eXpress</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF" text="#000000" alink="#006633" vlink="#996600" link="#006633">
<!-- Header -->
<jsp:include page="/dat/common/RoxHeader.jsp"/><!-- End Header -->
<CENTER>

<FORM METHOD="POST"

<CENTER>
  <TABLE border ="1" WIDTH="580" cellspacing=0 cellpadding="5" cellspacing="1">
<!--- Begin error message table --->

     <FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1">
      To select a record, click on the major in that record.
      If the Major field is not selectable, the program is not available at the current time.
     <P>
     </FONT>
    <TR>
     <TH BGCOLOR="PALEGREEN" ALIGN="CENTER" WIDTH="50"> <FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1">Action</th>
     <TH align=center BGCOLOR="PALEGREEN" WIDTH="50"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1">Status</th>
     <TH BGCOLOR="PALEGREEN" ALIGN="CENTER" WIDTH="50"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1">Type Of Audit</th>
     <TH BGCOLOR= "PALEGREEN" ALIGN="CENTER" WIDTH="100"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1">Degree Program</th>
     <TH BGCOLOR="PALEGREEN" ALIGN="CENTER" WIDTH="50"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1">Date&Time</th>
   </TR>
       
       
       <%
       try{
       
       
       while(vewAuditList.getNext())
       { %>
       
             
     <TR>
      <TD><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><INPUT TYPE="SUBMIT" SIZE=10 NAME="darssub" VALUE="Refresh">  </TD>
      <td><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"> <%=vewAuditList.getStatus() %></td>
      <td align="center" ><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><%=vewAuditList.getUserid() %></td>
      <td align="center"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><%=vewAuditList.getWebtitle() %></td>
      <td align="center"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"> <%= vewAuditList.getLastmoddate() %> </td>
     </TR>
    <% }
       }catch(Exception ex){
           out.println("this is null");
           out.println(ex.getMessage());} %>
       
   
    </TABLE BORDER>
 </TABLE>
</FORM>
</CENTER>

everything looks ok..

have u checked this page

>> <jsp:include page="/dat/common/RoxHeader.jsp"/>

also I hope you have the action tag in this..

>> <FORM METHOD="POST"


vemul
Hi Vemul,
      I do have the action tag, and I also have checked the <jsp:include page="/dat/common/RoxHeader.jsp"/>,  This is just a header page and it displays some static data on to JSP, Could u plz tell me the situations, in which we get this error,
ava.io.IOException: "Error: Attempt to clear a buffer that's already been flushed"  Becaz Iam pretty sure my JSp is fine, and there is something wrong  when I try to retrive the value
<%= vewAuditList.getLastmoddate() %> , this returns String.
Thanks in advance
shiv
the possible situation the above error can occur is the one stated above and also when the buffer size is too small..

ie.
When page has set error page and there
is exception raised during page processing, default action is catch the
exception, clear buffer and forward to error page. But when buffer is small,
it's flushed before catching exception, and buffer clear failed.

why don't u start debugging it one by one ie.
remove this line
<%= vewAuditList.getLastmoddate() %> , this returns String.

and see if it works fine, do the same for the rest and let's see where it could be going wrong..

vemul
to increase the buffer size, do this..

<%@ page buffer="32kb" %>

vemul
Hi Vemul,
           I did debug, if I remove this line <%= vewAuditList.getLastmoddate() %>, it wrks fine, and I figured why it is was giving that error, It was becaz there was a Data Type mismatch while getting the lastmoddate.
     There is one more question, could u tell me how can I format the date  coming from oracle, like the date from oracle comes like this 2002-11-08 13:36:38.0 with this method resultSet.getString(date) and I wanted to display the Date as 02/11/08 13:36:38 pm, Could u plz tell me how we can do that, I
Thanks for your help
shiv
do u have permissions to change the sql query on the oracle end, if so, you could change it there itself

Hi Vemul,
                As u r correct we can change it there itself, but I wanted to do it on the Java side, Could u tell me how to handle it at the Java end, So that I can display on the JSP as desired
Thanks in advance
shiv
try this..

SimpleDateFormat formatter = new SimpleDateFormat("yy/MM/dd HH:mm:ss");
String s = formatter.format(date);
btw, I hope your myDate is of Date format.. got this doubt after seeing one of your above comment where it says

myDate = resultSet.getString(date);

change it to myDate = resultSet.getDate(date);

and then apply the formatter on myDate

vemul
hi Vemul,
                but getDate only gives  just Date, not the time, and I want to represent both time and date, So I have used the getString(date), which gives me both Date and time.
In which case Iam not able to use the String s = formatter.format(date); As my date is in String.
Thanks in advance
shiv


      SimpleDateFormat formatter = new SimpleDateFormat("yy/MM/dd HH:mm:ss");
               String s = formatter.format(date);
>> but getDate only gives  just Date, not the time

are u sure about this.. give it a try and see.. meanwhile I can write a simple function to convert your string to the format you want..

vemul
ASKER CERTIFIED SOLUTION
Avatar of vemul
vemul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank u very much vemul
no problem.. good luck

vemul