When I specify the root of the "/" project in web.xml, it does not work when I try to display a picture in JSP, and as soon as I redirect to / signIn through the filter, the picture is displayed.

---структура такая--- webappp -> images -> default.jpeg -> WEB-INF -> views -> signIn.jsp ---в браузэре--- при загрузке на cars/ ничего не показывает при редиректе на /cars/signin/ показывает ---url в <img src="images/default.jpeg">--- 

I would like to understand why this is so?

  • Specify the full path from the root and everything will be okay. - And
  • As I just did not specify both /images/default.jpeg and ../../images/default.jpeg and $ {pageContext.request.contextPath} /images/default.jpeg and not only - Vardan Matevosyan

1 answer 1

Initially, on the JSP page, the image is displayed as follows:

 ${pageContext.request.contextPath}/images/default.jpeg 

What is your contextPath?

  • When switching to / cars / signin / url and with src = "images / default.jpeg" everything shows me, but when I remove the redirect and gkd it becomes just cars / even $ {pageContext.request.contextPath} / images / default .jpeg does not work - Vardan Matevosyan
  • And yet, what is the contextpath? Where is the application? Look in IDEA Run / Debug Config -> <server> -> Deployment tab -> Application context - Oleksiy Morenets
  • @ Morenets like this / cars - Vardan Matevosyan