Hi All,
In Work Detail Module, 3 sub modules are--> 1.create, 2.update, 3.correct.
In CREATE Work Detail page, i ll add data and upload photos of work details in createworkdetail.jsp. photos ll stored in D:\CMSMTDP_WorkDetailImages\Anekal\n1.jpeg
In updateworkdetail.jsp & correctworkdetail.jsp(see attached screen pics) if i click on image it ll show error(refer getOutputStream already response.txt) but image is visible n pop in new window.
code for downloaded file(D:\CMSMTDP_WorkDetailImages\Anekal) & to view in jsp
public static void downloadFile(String fileName,HttpServletResponse res) throws WebException
{
ServletOutputStream outStream = null;
int bytesRead=0;
byte [] byteArray = new byte[4096];
System.out.println("filename===>"+fileName);
if(null != fileName)
{
try
{
System.out.println("inside prior to execution download");
FileInputStream is=new FileInputStream(new File(fileName));
res.setContentType("image/jpeg");
outStream = res.getOutputStream();
bytesRead = is.read(byteArray);
while (bytesRead!= -1)
{
outStream.write(byteArray, 0, bytesRead);
bytesRead = is.read(byteArray);
}
// Flush and close stream
outStream.flush();
outStream.close();
is.close();
}
catch (FileNotFoundException e)
{
//throw new WebException(e);
e.printStackTrace();
}
catch (IOException e)
{
throw new WebException(e);
}
}
}
error getting in console:
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(R esponse.java:610)
at org.apache.catalina.connector.ResponseFacade.getWr iter(ResponseFacade.java:198)
at javax.servlet.ServletResponseWrapper.getWriter(Ser vletResponseWrapper.java:112)
at org.apache.jasper.runtime.JspWriterImpl.initOut(Js pWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffe r(JspWriterImpl.java:118)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspW riterImpl.java:173)
at org.apache.struts.tiles.taglib.InsertTag$InsertHan dler.doEndTag(InsertTag.java:893)
at org.apache.struts.tiles.taglib.InsertTag.doEndTag( InsertTag.java:465)
at org.apache.jsp.jsp.Common.CommonLayout_jsp._jspx_m eth_tiles_005finsert_005f0(CommonLayout_jsp.java:1 88)
at org.apache.jsp.jsp.Common.CommonLayout_jsp._jspSer vice(CommonLayout_jsp.java:145)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.doI nclude(ApplicationDispatcher.java:535)
at org.apache.catalina.core.ApplicationDispatcher.inc lude(ApplicationDispatcher.java:472)
at org.apache.struts.action.RequestProcessor.doInclud e(RequestProcessor.java:1110)
at org.apache.struts.tiles.TilesRequestProcessor.doFo rward(TilesRequestProcessor.java:292)
at org.apache.struts.tiles.TilesRequestProcessor.proc essTilesDefinition(TilesRequestProcessor.java:271)
at org.apache.struts.tiles.TilesRequestProcessor.proc essForwardConfig(TilesRequestProcessor.java:332)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:232)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at in.gov.mrc.kstd.arch.web.WSSORequestFilter.doFilte r(WSSORequestFilter.java:141)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
please need solutions for this problem. its very urgent..
thanks in advance..