I want to call a Servlet from img src. I have defined a Servlet class with name ImageProducerServlet and registered it in web.xml:
<servlet>
<servlet-name>ImageProducerServlet</servlet-name>
<servlet-class>com.company.servlet.ImageProducerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageProducerServlet</servlet-name>
<url-pattern>/imageproducerservlet</url-pattern>
</servlet-mapping>
In this servlet's doGet I just wrote a System.out
. Now From the JSF page I am calling that servlet as:
<img src="/imageProducerServlet" id="id"/>
I was expecting that it would print the System.out! But it doesn't.
The URL for the page where the img is added is:
If I write in the address bar the follwoing URL:
and press enter then the servlet's doGet is executing.
I am unable to find it's solution.
It will be very helpful if I get your suggestions.
Thanks and regards.