IMG tag does not bring image - html

I have a web application, where i am storing all the images in a folder which is totally outside WEB-INF folder or webroot folder. When the jsp to display the image is called, before displaying it, i am moving the concerned image files to WEB-INF/images folder and then setting the path in the html IMG tag. My question is
Is this good design?
Also even though the image is moved to WEB-INF/images folder, the page does not display the image always, it displays sometimes and sometimes it doesnt. I dont know how to debug this problem.
I am using springs and spring security.

This is not a very good design. In many cases, server will cache web application data so if the image was not there it will never find out that it appeared in place. That's, probably, causing the inconsistency that you observe as there may be other factors affecting caching.
The right choice would be to provide a servlet that serves your image data upon request from the file.

Related

HTML image doesn't loud from GOOGLE CLOUD

I have minimal knowledge of coding but I just spent the past 6 hours trying to resolve this issue.
Go here to see the image I am trying to have load.
If I am suppose to chance the SRC lines, how and where do I do that?
The HTML image loads perfectly from my computer.
Like what #mlegg said, I get the same error when trying to go to your link. It looks like that is no longer a valid URL or there is some form of security on it so it's only accessible from your computer (since you said it works from your computer?).
It could also be getting pulled from your browser cache if it was a good URL at one time. Try doing a Shift + Refresh of the page or purposely clear your cache.
If you have the image locally you could try uploading to a different web based repository and src it from there.
Just to cover all bases, I trust you know how to put an image on a web page using the img tag:
<img src="http://lorempixel.com/400/200/">
You might also want to try a different image that you know is available and accessible. You can use the URL above for lorempixel.com or you can scrounge up a different image from a Google Images search.

Some weebly features don't work when exporting to HTML and hosting on a different server

Recently I've been tasked with redesigning a website for the current company I'm working at. I've been using weebly to make the site, and then exporting the HTML to be re-hosted on the company's servers.
However, I've noticed that some functionality in weebly's code has stopped working. I imagine this might be due to weebly hosting some elements on their own servers, but this is merely a beginners best guess.
1. The picture for the logo on the banner does not appear once the HTML is rehosted
For comparison, here's the site while hosted on weebly:
http://mjmacoustique.weebly.com/
and the site on the company's servers:
http://www.mjm.qc.ca/redesign2015/
When weebly hosts, the ''MJM'' image should be on the top left and function as a return to home page button when clicked. However, when it's hosted on the company's server, the image is not found.
2. On Firefox, the background image of the home page is replaced with an all black background
When opened in firefox, it fails to load the background image of the main page.
Any help or solutions to these problems would be greatly appreciated.
Thanks.
I can help with question #1: the logo is hosted on weebly's servers, but in the html it's written in a shortcut method like this example: /uploads/2/6/8/5/26851316/1434298489.png"
the easy workaround would be to keep the weebly version of the site working, in in the html change the src value of the missing images to something like this http://mjmacoustique.weebly.com/uploads/2/6/8/5/26851316/1434298489.png
So you haveto add the http://YOURSITE.weebly.com before all the src values of your images.
otherwise, just load all the images you need on a blank page of the site on your servers, copy image urls of those and replace the urls in the html with that.
Hope that helps?
The firefox issue might also be solved if all your src values are linked correctly but I cannot be sure about that.
When I tried exporting a site from weebly, some assets were missing from the zip it produced. This resulted in some images failing to appear because they simply weren't there. I don't know how often this happens (or if it happens only for some sites), but weebly's export feature definitely seems to have bugs.
I worked around this by using wget to recursively fetch the content that weebly was hosting. Then I hand-copied the missing assets (and only the missing assets) from the directory structure saved by wget and merged them into the directory structure from weebly's export zip. This is time-consuming, but necessary since the directory structure fetched by wget includes dynamically-generated content (meta data for weebly's editor, assets with decorated names, etc) that you probably don't want in the content you host elsewhere.

Partial Content 206 status code when loading an image

I have a site that has multiple images being displayed on a page.
These are all varying in size but are in the region of 9MB-15MB.
They are all loading fine except for one. I get a 206 Partial content status.
I have done some research and found on StackOverflow a couple of questions relating to this, but they talk about it in relation to loading a video. But my problem is with an image.
The annoying thing is that all other images are loading just fine, even ones from the same directory and the same page.
Things, that I have checked:
The image is definitely there in the directory.
The image has full 777 privilege as does its folder.
It is 10.6MB, but as I have said, I have other images of this size and bigger which are loading with no problem.
I am able to open the image on the computer (as I am on my local).
Image is being loaded in a standard img tag.
This should only happen if you are sending a Range header in your HTTP request. Does this happen, too, if you are using another browser? If so, this is probably some sort of misconfiguration or bug on the server side. If not, your browser seems to be messy, then I would try to delete the cache or, if this doesn't help, to restart.

Images Not Displaying on HTML Index Page, but Show up on All Other Pages

I have quite the conundrum. Background- I have a webpage I made for fun as an easter egg for an internal site on my company's network. The index page isn't rendering the images and it's giving off a 404 not found error, even though I've triple checked and they're in the appropriate directory and I can open them up and view up without issue.
Pages that are linked to the index page DO get their pictures rendered. The webpages and the pictures are both in their own directories so I'm really not sure what could be going on. The tag is correct as well as the file name.
For example-
On my index page I have <img src="pics/opslogo.jpg"> which should point to http://[internal site]/html/Old_Ops_Website/pics/opslogo.jpg, which it does according to the page source, but it doesn't render even though I know the picture is in there.
On a separate page I have <img src="pics/connection.jpg"> which should point to http://[internal site]/html/Old_Ops_Website/pics/connection.jpg, which it does, and it DOES render correctly.
Interestingly enough the pictures that won't render when hitting the site from the network DO render correctly on the host machine itself.
Here are the paths, taken from "copy-shortcut", to the images from the non-working page and a working one, respectively-
http://[internal site]/html/Old_Ops_Website/pics/ops-logo.jpg
http://[internal site]/html/Old_Ops_Website/pics/connection.jpg
Given those pieces of information, I'm absolutely bewildered as to why this isn't working.
Not sure if it makes any difference but the actual root of the website is located in "C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT" while the page I'm working on is located in "C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT\html\Old_Ops_Website". Both directories have index files.
I tried changing the index file to "test.html" and hitting it via "http://[internal site]/html/Old_Ops_Website/test.html" with the same results.
Also tried "<img src="./pics/opslogo.jpg"/>", just in case, but no-go still.
Next steps taken-
Ok so I tried it with the images that I know for sure to be working on other pages and they show up on the index page as well. I still don't understand why the others won't show up since all the images are located in the exact same directory and when viewing the website from the host server all images render correctly. Next I tried to link the images that aren't working to one of the other pages and they don't work there either. I've triple checked and the images are definitely in the right directory and in the correct format and I can open them up and view them.
What could be causing these specific images to not render on any of my pages, yet they render perfectly from the host machine itself?
Edit, more details-
I went ahead and set the site up on my public dev server- here. As you can see here- pics the photos are in the correct directory, the HTML page is referencing the correct images, but nothing is coming up. FYI - I didn't create this site. This is about 10-15 years old which is why I'm hiding it on our current site as an easter egg for people to get a laugh at.
don't you realize your file name is wrong.
try:
<img src="pics/opslogo.JPG"/>

Loading images from various sources in QTWebKit

I am trying to create a "smart" web browser to load local images. Basically it works as a GUI for an application. I am using QTWebKit to power the browser, the problem is that the images of a given page can be found in different places, some are local files, others are in different resource files.
For example:
an HTML node to load image x.jpg can look like <img src="x.jpg"> and for image y.gif on the same page it can be <img src="y.gif">, now x.jpg is a local file that can be either in the root directory or in some other place. y.gif on the other hand can be in a resource file.
I want the web browser first to set the paths to all possible sources and once the page has been loaded or preferably while the page is loading searches for the images and loads them from their original path.
I considered the option of reading the HTML data first, parse it and search for the resources one by one, then edit the html to include the full path of the image but that would take a long time than what I want and it isn't practical.
Can any one put me on the right direction or does any one have any ideas on how such a design can be implemented.
EDIT: I have manage to delegate the requests by overriding the QNetwrokAccessManager and QNetwrokReply and been able to get the path to the image. The only problem is loading the image into view. I am currently using QHttp to handle the incoming requests but so far I haven't been able to load the image.
been trying to use QHttp's Get() function and passing the path to the jpg image as (file:///path/to/image) and also tried using the local path but nothing is working.
Take a look at How to tell QWebPage not to load specific type of resources?
You need the same approach but instead of dropping request by constructing QNetworkRequest with empty QUrl you need to pass url to the file on the disk.