We are trying to open excel files using a servlet. The code is hosted on Websphere Portal Server. The servlet accepts request from a jsp file and opens the requested excel file from the required location. There are two WPS servers having their individual URLs and there is one clustered URL for these two servers.
Now the problem is that for all the excels which are less than 33KB in size, we are getting junk data when we try to open the same from the clustered URL. But the same excel opens up perfectly fine from the individual server URLs. Excels which are more than 33 kb are not giving any problem anywhere. The code we are using is:
URL url = new URL(excelLocation); URLConnection urlcon = url.openConnection(); res.setContentType( urlcon.getContentType() ); // MIME type
This is really a very weird situation. Any help would be really commendable.
Also, we are getting the following warning in the logs:
00000087 ServletWrappe E SRVE0014E: Uncaught service() exception root cause /checkthis.jsp: SRVE0199E: OutputStream already obtained [6/10/07 3:02:18:460 EDT] 00000087 LocalTranCoor E WLTC0017E: Resources rolled back due to setRollbackOnly() being called. [6/10/07 3:02:18:462 EDT] 00000087 WebApp E SRVE0026E: [Servlet Error]-[/checkthis.jsp]: java.lang.IllegalStateException: SRVE0199E: OutputStream already obtained at com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:489)
Author and all-around good cowpoke
Joined: Mar 22, 2000
Uncaught service() exception root cause /checkthis.jsp: SRVE0199E: OutputStream already obtained
The reason is right in front of you - the JSP has already obtained the output stream for character output because thats what JSP do.
You need to put your code in a servlet where there is no automatic opening of the output stream.