dynamically output a image via struts insted of servlet
843836May 8 2005 — edited May 10 2005Hello,
I want to know how to dynamically output a image via struts insted of servlet;
I can work it fine with the serverlet, this how i get it to work via serverlet:
java class:
public class ImageServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
..
..
}
}
in web.xml :
<servlet>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>com.admin.transferform.ImageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageServlet</servlet-name>
<url-pattern>/ImgServlet</url-pattern>
</servlet-mapping>
and access the pic in[b] jsp :
<img src="/ImgServlet"></img>
<br>
I just want to know, how do i access via struct?
i change the java class to :
public class ImageServlet extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
..
..
}
}
and in struts-config.xml :
<action
path="/image"
type="com.admin.transferform.ImageServlet">
</action>
and i have tryed both these in jsp but none did work:
in JSP :
<img src="/image"></img>
or
<html:image src="/image" />
can some one tell me, where did i went wrong pleaseee :)