From: Victor N. <vic...@oi...> - 2004-11-04 20:25:34
|
Hi, Thank you for your outstanding software. I am using struts in a web application. As you are familiar, struts uses a single action servlet which the developer views as a black box. My question: When I encode my chart in an action class, and then forward to a jsp to display that chart, I see the chart but when I print the stacktrace I get the message: java.lang.IllegalStateException: Cannot forward after response has been committed I encode by saying. JPEGEncoder13.encode( axisChart, 1.0f, response.getOutputStream()); in my action class. Is there a way to use another output stream and then display this output stream in a jsp page? Or do I have to extend the action servlet? Thank you . Victor Nammour Software Developer Office of Information Technology Trenton, NJ |
From: Chris W. <cw...@go...> - 2004-11-04 21:21:44
|
On Thursday 04 November 2004 02:25 pm, Victor Nammour wrote: > Hi, > Thank you for your outstanding software. > I am using struts in a web application. As you are familiar, struts uses > a single action servlet which the developer views as a black box. > My question: When I encode my chart in an action class, and then forward > to a jsp to display that chart, I see the chart but when I print the > stacktrace I get the message: > java.lang.IllegalStateException: Cannot forward after response has been > committed > > I encode by saying. > JPEGEncoder13.encode( axisChart, 1.0f, response.getOutputStream()); > in my action class. > Is there a way to use another output stream and then display this output > stream in a jsp page? Or do I have to extend the action servlet? > > Thank you . > > Victor Nammour > Software Developer > Office of Information Technology > Trenton, NJ > It is never a good idea to try to output binary data from a JSP page. They were not intended for that. If you are trying to output just a chart image, and no html, maybe you need a different struts view (not sure how that is done, not a struts person). If you want to display the image of a graph on a jsp page, you should probably save the image to a file location, and then display the graph as an image normally would be done in html. Chris |
From: Nathaniel G. A. <nat...@ya...> - 2004-11-04 21:52:31
|
something is getting written to the reponse before you encode the chart. Check your code and if you are not doing it then Struts is. If Struts is, you could always add a Servlet which renders the Chart. I would not write the image to a file, as the performance of that would not be good. --- Chris Ward <cw...@go...> wrote: > On Thursday 04 November 2004 02:25 pm, Victor Nammour wrote: > > Hi, > > Thank you for your outstanding software. > > I am using struts in a web application. As you are familiar, struts uses > > a single action servlet which the developer views as a black box. > > My question: When I encode my chart in an action class, and then forward > > to a jsp to display that chart, I see the chart but when I print the > > stacktrace I get the message: > > java.lang.IllegalStateException: Cannot forward after response has been > > committed > > > > I encode by saying. > > JPEGEncoder13.encode( axisChart, 1.0f, response.getOutputStream()); > > in my action class. > > Is there a way to use another output stream and then display this output > > stream in a jsp page? Or do I have to extend the action servlet? > > > > Thank you . > > > > Victor Nammour > > Software Developer > > Office of Information Technology > > Trenton, NJ > > > It is never a good idea to try to output binary data from a JSP page. They > were not intended for that. If you are trying to output just a chart image, > and no html, maybe you need a different struts view (not sure how that is > done, not a struts person). If you want to display the image of a graph on a > jsp page, you should probably save the image to a file location, and then > display the graph as an image normally would be done in html. > > Chris > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > jCharts-users mailing list > jCh...@li... > https://lists.sourceforge.net/lists/listinfo/jcharts-users > __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com |
From: Chris W. <cw...@go...> - 2004-11-04 22:32:30
|
On Thursday 04 November 2004 03:52 pm, Nathaniel G. Auvil wrote: > something is getting written to the reponse before you encode the chart. > Check your code and if you are not doing it then Struts is. If Struts is, > you could always add a Servlet which renders the Chart. > > I would not write the image to a file, as the performance of that would not > be good. I am not sure what you mean 'as the performance of that would not be good'. The way I use it, it is better. Instead of creating charts with every request, I only create a chart when data has changed, and save it as a name my html page will know. This way, I only look up an image without needing to create the image every time. Of course, the servlet accessed by an image tag would be the best way to access a chart from struts if you needed to render the chart with every access, as you would not need two file operations every time (write, then read) Chris |
From: Nathaniel G. A. <nat...@ya...> - 2004-11-05 01:25:34
|
The cost of rendering a chart is relatively small, so unless you have a large load, caching the image provides little benefit and adds complexity. However, if your data changes infrequently and your server is under load, caching makes sense. The same is true of using any type of caching. For the majority of applications, writing the chart to a file is uneeded. Some people think they HAVE to write the chart to a file to use it in an img tag. --- Chris Ward <cw...@go...> wrote: > On Thursday 04 November 2004 03:52 pm, Nathaniel G. Auvil wrote: > > something is getting written to the reponse before you encode the chart. > > Check your code and if you are not doing it then Struts is. If Struts is, > > you could always add a Servlet which renders the Chart. > > > > I would not write the image to a file, as the performance of that would not > > be good. > > I am not sure what you mean 'as the performance of that would not be good'. > The way I use it, it is better. Instead of creating charts with every > request, I only create a chart when data has changed, and save it as a name > my html page will know. This way, I only look up an image without needing to > create the image every time. > > Of course, the servlet accessed by an image tag would be the best way to > access a chart from struts if you needed to render the chart with every > access, as you would not need two file operations every time (write, then > read) > > Chris > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > jCharts-users mailing list > jCh...@li... > https://lists.sourceforge.net/lists/listinfo/jcharts-users > __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com |
From: Chris M. <ch...@de...> - 2004-11-05 04:07:59
|
Plus you need to write a file collector as well to tidy up the cache directory ... C > -----Original Message----- > From: jch...@li... > [mailto:jch...@li...] On Behalf > Of Nathaniel G. Auvil > Sent: Friday, 5 November 2004 2:25 p.m. > To: jch...@li... > Subject: Re: [jCharts-users] jCharts in Struts > > > The cost of rendering a chart is relatively small, so unless > you have a large load, caching the image provides little > benefit and adds complexity. However, if your data changes > infrequently and your server is under load, caching makes > sense. The same is true of using any type of caching. > > For the majority of applications, writing the chart to a file > is uneeded. Some people think they HAVE to write the chart to > a file to use it in an img tag. |
From: Chris W. <cw...@go...> - 2004-11-05 15:11:02
|
On Friday 05 November 2004 04:09 am, Chris McKay wrote: > Plus you need to write a file collector as well to tidy up the cache > directory ... > > C In my case, I don't need to delete a 'cache' folder, as it never grows beyond a set size of images. The image names are reused each time the graphs are created, so that static names can be used on web pages. It may not be the case for most people, but I have to generate my data from a database for each chart, and I have from 2 to 8 charts on a page, with my final result being a PDF of 30-40 pages. In my case, I think the cost of generating the graphs is high, with the individual graphs changing infrequently. I have used the servlet in an img tag before, and it appears that most people here like that method and recomend it first, but I have always liked the idea of reducing server load to the web server. If you have highly dynamic graphs, I guess you have no choice. I have also contemplated moveing the servlet graph generators to a seperate 'image' server, but decided that still would be best with more dynamic charts than I have. Mine only change when a user changes input data, not with an automatic process such as recording temperature data. All things said, if the servlet in an image tag is the preferred method of this list, I don't need to confuse new people by suggesting saving to a file again, but I did put thought into it before making my decision. Chris |
From: Nathaniel G. A. <nat...@ya...> - 2004-11-05 18:42:08
|
Ok. So it sounds like your load is fairly high avg 5 charts per page * avg 35 pages = 175 charts per pdf. Caching could make sense here; I do not know all your performance metrics, like how long it takes to generate charts versus the whole pdf, versus fetching/computing the plot data, user load, size of box, etc... I would suggest doing on the fly charts and then run using cached charts to see what the difference is and how it fits into your overall performance plan. --- Chris Ward <cw...@go...> wrote: > On Friday 05 November 2004 04:09 am, Chris McKay wrote: > > Plus you need to write a file collector as well to tidy up the cache > > directory ... > > > > C > > In my case, I don't need to delete a 'cache' folder, as it never grows beyond > a set size of images. The image names are reused each time the graphs are > created, so that static names can be used on web pages. > > It may not be the case for most people, but I have to generate my data from a > database for each chart, and I have from 2 to 8 charts on a page, with my > final result being a PDF of 30-40 pages. In my case, I think the cost of > generating the graphs is high, with the individual graphs changing > infrequently. > > I have used the servlet in an img tag before, and it appears that most people > here like that method and recomend it first, but I have always liked the idea > of reducing server load to the web server. If you have highly dynamic graphs, > I guess you have no choice. I have also contemplated moveing the servlet > graph generators to a seperate 'image' server, but decided that still would > be best with more dynamic charts than I have. Mine only change when a user > changes input data, not with an automatic process such as recording > temperature data. > > All things said, if the servlet in an image tag is the preferred method of > this list, I don't need to confuse new people by suggesting saving to a file > again, but I did put thought into it before making my decision. > > Chris > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > jCharts-users mailing list > jCh...@li... > https://lists.sourceforge.net/lists/listinfo/jcharts-users > __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com |