2
My question is the following, can I by relative way link my . JSP to a library within the project directory? Or only in the server directory: Webapps, etc?
At the moment, when I want to show an image on my system, I do the following:
<img src="http://localhost:8080/minhaLogo.png" width=30>
Which is in the directory:
C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.5\webapps\ROOT\minhaLogo.png
Everything below webapps/root is easily accessible.
However, I would like to use the logo within a relative path of my project folder structure:
I tried it in many ways, but I didn’t succeed, as much as the console says I had a HTTP GET 200
image does not load. It’s possible to do what I’m trying to do?
I tried something like, with several directory variations, but no success:
<img src="<%= request.getContextPath() + "/newLib/minhaLogo.png" %>" width=30>
Thank you very much.
EDIT:
As it is a test page, it is simply a page with the image in the body:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>teste link relativo</title>
</head>
<body>
<a class="bt"><img src="<%= request.getContextPath()%>/newLib/minhaLogo.png" width=30></a>
</body>
</html>
I’ll test, thank you
– user94991
although the tag is right on F12 <img width="30" src="/Qualiteweb_novo_10-08-18/newLib/myLogo.png"> and return a "HTTP GET 200", the image does not appear
– user94991
Could send the code of the page you use this image?
– Antonio Santos
I edited the question with the code, but since it’s just a test page, there’s not much :/
– user94991
I tested your code and it works perfectly related to tag img. There is nothing wrong not to show the image on the screen.
– Antonio Santos
I thought it had something to do with my company’s network, so I did the same thing on my personal computer and nothing
– user94991