0

I want to display an image in a particular in a jsp page and I am calling servlet from the tag but the control is never reaching the servlet. Can someone help me find the error in the logic or some syntax issue if any..?? This is the img tag of the jsp page:

 <img src="/controller/ImageServlet" alt="My image" height="200px" width="200px">

Is this the correct way to transfer the control to the servlet through img tag? Here "controller" is a package under which I have defined "ImageServlet" servlet.

David C
  • 7,204
  • 5
  • 46
  • 65
  • What is the mapping for `ImageServlet` ? – Arnaud Apr 26 '16 at 17:01
  • You probably want `src="${pageContext.request.contextPath}/controller/ImageServlet"`. Or, if you use the JSTL, `src=""`. Also, the class name and package name are irrelevant. What matters is the mapping of the servlet. – JB Nizet Apr 26 '16 at 17:03
  • ImageServlet /new/WebContent/profile @Berger – Shubh Sinha Apr 26 '16 at 19:59
  • I have tried the former way of defining the "src" which was mentioned by you but it didn't work in my case. @JBNizet – Shubh Sinha Apr 26 '16 at 20:03
  • In the future, when things appear to be failing in client side, press F12 to open the web developer's toolset. In the network monitor and console you should have noticed a HTTP 404 error (which in turn is also explained here: http://stackoverflow.com/q/11731377) – BalusC Apr 26 '16 at 20:27

0 Answers0