Hi all
Strange behaviour observed. Perhaps someone with more experience can explain.
I have a NetBeans project page that pulls a list of products from a database.
There is a script block in the jsp that parses the list and creates image tags in the body of the jsp.
I have been trying for 4 days to figure out why the images don't render in the browser thinking it was a relative paths issue
because there seems to be a lot on the net associated with people having relative path issues.
However, today I had the bright idea of hardcoding an image tag into the jsp and moving the image around the project
file system to see where in the file sysem the app actually picks it up. Eureka. Found it. Its nothing at all to do
with relative paths. Don't know why I didn't think of that sooner. Never mind.
So what's the problem?
Here it is. Now that I know where the images should be I modified my dynamic image tag generation code to suit.
But, alas, still no image render. What the hell?
So, I hard coded the image tag in the script block to one of the images defined in my data. Guess what? It renders fine in the browser.
But when I build the image tag dynamically from my data within the script block it doesn't.
Even though, when I look at the rendered html in the browser source, the image tags are identical.
Here is the scriptlet code
<% Category _category = new Category(); _category.setCategoryid(41); List<CategoryProductItem> _cpilist = SampleServletBean.DAC().CategoryProductListPage(_category); for(CategoryProductItem cpiitem : _cpilist) { %> <%= "In Product List " + String.valueOf(cpiitem.Productid()) + cpiitem.Productname() + "<br />" %> <% String _imageURL = "Images\\dbe83c66-054c-4604-a71d-45d02dba73ca.png"; String _imageURL2 = "Images\\" + cpiitem.Productimagefilename() + "." + cpiitem.Productimageextension(); String imglink = "<img src=\"" + _imageURL + "\" alt=\"\" />"; String imglink2 = "<img src=\"" + _imageURL2.toLowerCase() + "\" alt=\"\" />"; %> <%=imglink %><br /><br /> <%=imglink2 %><br /><br /> <% } %>
.... and here is the html source rendered in the browser for the two images
<img src="Images\dbe83c66-054c-4604-a71d-45d02dba73ca.png" alt="" /><br /><br /> <img src="images\dbe83c66-054c-4604-a71d-45d02dba73ca.png" alt="" /><br /> <br />
Identical as you can see.
The top one renders ok.
The second one doesn't.
See the attached pic.
Twilight zone?
Is it possible thet the page is being rendered at the second image tag point BEFORE the image is downloaded to the browser.
Is this a known synch problem?
What do you reckon?
All suggestions appreciated.
Thanks
Ray