Servlet Invoked Multiple Times For Each Request

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
tphan
Posts: 1
Joined: Wed Dec 02, 2015 6:26 am
antibot: No, of course not.

Servlet Invoked Multiple Times For Each Request

Post by tphan » Wed Dec 02, 2015 6:35 am

Hello, I'm using a servlet to render a PNG image directly for <img> tags within a JSP file. Our code is similar to the example in the URL below. We use 'ChartUtilities.writeChartAsPNG' to generate and return the image.

http://www.avajava.com/tutorials/lesson ... rvlet.html

My issue is that it seems that the servlet is invoked twice for each image when invoke from a browser. This is contributing to slower performance as only one request is really needed. Can someone provide insight into why this is occurring and how we can correct this to one servlet request per image? Thanks.

Tri

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Servlet Invoked Multiple Times For Each Request

Post by matinh » Thu Dec 03, 2015 12:10 pm

This is off-topic, as JFreeChart is definitely not the component, triggering any Servlet request.
The example you linked to, looks good for me.

My guess is, that the HTML/JSP-page is somehow triggering the double request. What, if you enter the Image-URL in the browser? Does it still fire two requests? I bet not.

hth,
- martin

Locked