Call a servlet by an img tag
843841Oct 26 2004 — edited Oct 26 2004I,ve a little problem.
I need to call a servlet (gif.class) using an img tag.
The servlet is placed in Tomcat5/webapps/Prova/WEB-INF/classes and the HTML page is placed in Tomcat5/webapps/Prova.
Which is the right src in the <img src="">???
And if i want the servlet return not a new html page but the image, what should i write in the doGet method?
I tried to use this servlet
public class gif extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("image/gif");
PrintWriter out=response.getWriter();
out.println("<HTML><BODY>");
out.println("<h1>Ciao<h1>");
out.println("<img src=\"http://127.0.0.1:8080/Prova/px.gif\">");
out.println("</BODY></HTML>");
}
but i call it with a form->submit command and it return a html page.
I need the page load the image using a servlet.
the image(px.gif) is placed in Tomcat5/webapps/Prova.
Thanks