V
vsingr
I am trying to display an image in my jsp. The image is a pie chart
generated dynamically. i use another jsp to generate the image and
include this in my other jsp where the image is displayed. However when
I do so I get the following exception in my console though the image
appears. Can any one help in this regard? I am also including the
snippet which shows the image generation and the include.
Thanks in advance
Sriram
The code for generating the image is
<% // Please don't add spaces at the beginning or the end of this file.
This may
//result in the graphs being not displayed on the page
correctly %><%@
page language="java" import="java.io.*,
com.trp.jvl.iiwc.BasicSession" %><%
try
{
String chartID =
request.getParameter("chartID");
//Get the binary data for the chart gif from
the session and write
//it to the output stream
BasicSession pgtCache =
(BasicSession)request.getSession().getAttribute("pgtCache");
byte [] bytes = (byte[])pgtCache.get(chartID);
if ( bytes != null )
{
response.setContentType("image/jpeg");
OutputStream outStream = null;
outStream = response.getOutputStream();
outStream.write(bytes);
outStream.flush();
}
}
catch (Exception e)
{
e.printStackTrace();
}
%>
The include happens as below
<img
src="/portfolioAnalytics/pages/portfolioAnalytics/portfolio/currentPieChart.jsp?chartID=targetChart"/>
WebGroup E SRVE0026E: [Servlet Error]-[OutputStream already
obtained]: java.lang.IllegalStateException: OutputStream already
obtained
at
com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:516)
at
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:202)
at
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:193)
at
org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:246)
at
org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:197)
at
org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:255)
at
org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:249)
at
org.apache.jsp._currentPieChart._jspService(_currentPieChart.java:110)
at
com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
generated dynamically. i use another jsp to generate the image and
include this in my other jsp where the image is displayed. However when
I do so I get the following exception in my console though the image
appears. Can any one help in this regard? I am also including the
snippet which shows the image generation and the include.
Thanks in advance
Sriram
The code for generating the image is
<% // Please don't add spaces at the beginning or the end of this file.
This may
//result in the graphs being not displayed on the page
correctly %><%@
page language="java" import="java.io.*,
com.trp.jvl.iiwc.BasicSession" %><%
try
{
String chartID =
request.getParameter("chartID");
//Get the binary data for the chart gif from
the session and write
//it to the output stream
BasicSession pgtCache =
(BasicSession)request.getSession().getAttribute("pgtCache");
byte [] bytes = (byte[])pgtCache.get(chartID);
if ( bytes != null )
{
response.setContentType("image/jpeg");
OutputStream outStream = null;
outStream = response.getOutputStream();
outStream.write(bytes);
outStream.flush();
}
}
catch (Exception e)
{
e.printStackTrace();
}
%>
The include happens as below
<img
src="/portfolioAnalytics/pages/portfolioAnalytics/portfolio/currentPieChart.jsp?chartID=targetChart"/>
WebGroup E SRVE0026E: [Servlet Error]-[OutputStream already
obtained]: java.lang.IllegalStateException: OutputStream already
obtained
at
com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:516)
at
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:202)
at
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:193)
at
org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:246)
at
org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:197)
at
org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:255)
at
org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:249)
at
org.apache.jsp._currentPieChart._jspService(_currentPieChart.java:110)
at
com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
at
com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at
com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)