i am saving my images through java coding in a folder called "files".
and in my jsp page i am trying to display that image using
<img alt="" src="${pageContext.request.contextPath}/files/IMG168.jpg"> But the image is not displaying! What could be the reason.
Please see the below images and suggest me solution for my problem.
You should put the files folder in WebContent directory.
Web pages contains as below
Web pages
|______page1.jsp
|______index.jsp
|______page2.jsp
|______WEB-INF
|______images
|______css
|
Just try this and see
<img alt="" src="../../files/IMG168.jpg">
Updated,
I think you have to get physical location of files folder and put it in to src. Example if your files folder in C:\visionbook\files your
src="C:\visionbook\files\IMG168.jpg"
Related
I have a webview app which load resources(css,js,images) from server. I would like it to load resources from the assets folder in the app. How can i do that?.
I tried using: <img class="after-splash" src="file:///android_asset/image.png"> but nothing works. I already have an asset folder in the app\src\main
If webview is loading a html page from assets folder and the code segment you mentioned is within the html file, relative file path will work fine
<img class="after-splash" src="image.png">
Also watchout for CORS errors if it is still not loading
<img class="after-splash" src="image.png" crossorigin="anonymous">
image.crossOrigin = 'Anonymous'
I want my image show up in receipt_failure.html via such thymeleaf expression :
<img th:src="#{/src/main/resources/images/icons-alert-circle.png}" />
Image itself has settled in such SpringMVC folder structure:
I do not get where issue comes from because seems like I keep path structure but I am getting such error on my local environment
I moved /images folder into /static folder then fix html like this:
<img th:src="#{/images/icons-alert-circle.png}" />
and issue has been fixed
problem:
<img src="#{/images/0.jpg}" alt="error occured"/>
I am using Eclipse and folder images is in src/main/resources/static/images and Thymeleaf template which uses:
<img src="#{/images/0.jpg}" alt="error occured"/>
is in folder: src/main/resources/templates
The image is for example: 1.jpg
No, th:src is 'Thymeleaf Standard Dialect'. If your project is properly set up, spring/thymeleaf will be able to find your image on the webserver (e.g. Tomcat) by the given relative path itself. You do not need any own controller.
I hope this will help you: https://stackoverflow.com/a/29475520/9158389
I have tried the image uploading code in java.Images are upload in -
D:\bridge\Project\.metadata\.plugins\ org.eclipse.wst.server.core\tmp0\wtpwebapps\bridghc\Example\image-folder\2nd page.jpg this directory.
This fully path is also inserted in database.When i fetch the path from database i get the same result but when i write
<img id="0" src="D:\bridge\Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bridghc\Example\image-folder\2nd page.jpg" name="txtrepimg0">.
In the web page i am not able to fetch the image.I got failed to load url.
Please help.
The src attribute in the img tag only accepts web addresses as targets, not local directories. So the path should look something like http://mysite/images/myimage.jpg
You should store relative path into database not Actual path of file. you should only store
file name, as your folder is fixed to store images
2nd page.jpg
and use the following in img tag
<img id="0" src="application_name/your-relative-path-of-image-folder/2nd page.jpg
" name="txtrepimg0">
like
<img id="0" src="/bridghc/Example/image-folder/2nd page.jpg" name="txtrepimg0">
In your case application name is bridghc
Try change your upload path to something relative to your website location.
For example, if your webfiles(html, css, javascript, etc...) are in:
D:\bridge\Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bridghc\Example
add a folder like "image-folder" in a relative path like
D:\bridge\Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bridghc\Example\image-folder
save the relative path in database
\image-folder\image.png
and use it in your website
<img id="0" src="\image-folder\image.jpg" name="txtrepimg0">
I'm working on a web project using java/ jsp/ servlets/ html/ css in eclipse tomcat, where everything is in the WebContent folder.
In my jsp files... When I try to include other jsp files (using a link like "/fileName.jsp" in jsp include directive) I can do that successfully.
But When I try to include image files (using a link like "/fileName.jpg" in the <img src=""> tag) nothing happens.
Nothing happens because instead of looking in the WebContent folder for image file it looks in the tomcat home directory, i.e.
Instead of looking at "http ://localhost:port/projectName/..." it looks at "http: //localhost:port/..."
Why does it look at the wrong location only with <img src=""> tags but not in <%# /> tag.
A workaround for this is that I start giving absolute paths "/projectName/..." However doing this means I'm hardcoding project name everywhere. This is what I do not want.
Don't include binary content in an ascii output. Why not just use the img tag? If you need to do something to produce a jpeg, I would use a Servlet.
Because the jsp-Links in the website are getting processed and the image links not. Either change the image path or develop an filter that changes the images'links.
Yes Templar, that could have been a way to solve my problem.
However, I simply changed the Context Root of my project from "Project Name" to "/" in Eclipse. This solved my problem.