hi ,
I am facing a problem that when i entered my search criteria then x and y axis comes dinamicaly from database.
But when ther is no value then its x axis will not get any data
so i got
java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.catalina.connector.Response.getWriter(Response.java:596)
exception.
I have go through the posted topic but its not worth.
now i want to show the message when i will not get any data but unable to do so.
help me out>. i am using this code to send chart on jsp in my servlet>>>timeSeriesChart = createChart(sFromDate,sToDate,createDataset(sNDC,listPBM,sFromMonth,sFromYear,sToMonth,sToYear));
request.setAttribute("timeSeriesChart",timeSeriesChart);
response.setContentType( "image/png" );
BufferedImage buf = timeSeriesChart.createBufferedImage(600, 420, null);
PngEncoder encoder = new PngEncoder( buf, false, 0, 9 );
response.getOutputStream().write( encoder.pngEncode() );
RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher("/TimeSeriesReportResult.jsp");
requestDispatcher.forward(request,response);
when chart is not come then how to show message
The problem you are facing here is that you have already committed output to the response stream before you forward to the jsp.
Depending on what the /TimeSeriesReportResult.jsp does...
Firstly you are writing out a stream of data with the content type of image/png
Then you attempt to forward the request on to a jsp which will probably have the content type of txt/html (or something along those lines)
You will need to have a servlet/jsp that writes out the chart as a stream, and a second page which calls this page. I would recommend a servlet rather than a jsp, however if it is a jsp file it will look something like the following (pseudocode only)
so for chart.jsp
Note that you can have NO whitespace or anything else in the file - the servlet is a better option
in the /TimeSeriesReportResult.jsp
<img src="chart.jsp">
Hope this helps
Depending on what the /TimeSeriesReportResult.jsp does...
Firstly you are writing out a stream of data with the content type of image/png
Then you attempt to forward the request on to a jsp which will probably have the content type of txt/html (or something along those lines)
You will need to have a servlet/jsp that writes out the chart as a stream, and a second page which calls this page. I would recommend a servlet rather than a jsp, however if it is a jsp file it will look something like the following (pseudocode only)
so for chart.jsp
Code: Select all
<%
timeSeriesChart = createChart(sFromDate,sToDate,createDataset(sNDC,listPBM,sFromMonth,sFromYear,sToMonth,sToYear));
response.setContentType( "image/png" );
BufferedImage buf = timeSeriesChart.createBufferedImage(600, 420, null);
PngEncoder encoder = new PngEncoder( buf, false, 0, 9 );
response.getOutputStream().write( encoder.pngEncode() );
%>
in the /TimeSeriesReportResult.jsp
<img src="chart.jsp">
Hope this helps