thanks & regards,<br />Sanjeev.
I am creating new (anonymous) Thread in my JSP and when I am trying to use out in that thread, it says that out needs to be declare as final.
You can always run the above thread as,
new Thread(new NamedClass(out)).start();
Don't do it - JSP are for character data, servlets are for binary as well as character data.
There is nothing to be gained by starting another Thread to write to the response.
final OutputStream outter = out;
thanks & regards,<br />Sanjeev.
thanks & regards,<br />Sanjeev.
<img src=<%="/mypack/fetchtheimage?no="+imageNo%>>
And my intention was to put the above <img> tag into a anonymous new Thread.
thanks & regards,<br />Sanjeev.
thanks & regards,<br />Sanjeev.
My problem is when user does access the next button before starting of the downloading of the first image (all the presentation got available but downloading of image takes few seconds.), it provide the first image not the second one. I would appreciate your suggestions regarding this.
thanks & regards,<br />Sanjeev.
Still trying to understand what you are attempting. See if this description is correct. You want to have a JSP generated HTML page which includes an <img tag - only one img per HTML page. This page also provides "previous" and "next" page links.
The img source is a servlet that reads an image from a URLConnection.
Your problem is that if the user clicks the next page link before the image is loaded, the new page does not get an image.
Perhaps the second attempt to open a URLConnection to the image source is getting refused because the first connection is still open.
Firstly, I assume that you have a good reason for using a URLConnection in your servlet to locate the image, e.g. not wanting the real image URL to appear in the HTML source. If that's not the case then I suggest you just use the SRC attribute of the HTML IMG tag as I can't see what other benefit you're getting.
Secondly, unless you have a very good reason for wanting to serve a very detailed and/or very large image on your page (600-700Kb is still a massive image for the web). Best practice guidelines suggest that your whole page should be no more than 100Kb at the outside as the vast majority of users won't wait around for a larger page to download. If you have control over the images I suggest you optimise them for the web using a tool such as Adobe Photoshop
Regarding the apparent difference in image size, I'm not sure what's going on there. Are you sure you have it right? How are you measuring the file sizes? If the image displays correctly in the browser it's extremely unlikely to be any different in size to that which you've read from the original URL.
thanks & regards,<br />Sanjeev.
Probably the others are too. Since there is only one copy shared by all requests, no wonder it gets confused as to which image to show.
You should never use an instance variable in a servlet for data that changes between requests.
thanks & regards,<br />Sanjeev.
thanks & regards,<br />Sanjeev.
Let me tell you a story about a man named Jed. He made this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
|