0

I am working on a simple example where I simply displaying a image using servlet:

public class ImageServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    response.setContentType("image/gif");  
    ServletOutputStream out = response.getOutputStream();  
    //Optain image icon
    ImageIcon icon = new ImageIcon("inbox/apple.gif");
    Image image = icon.getImage();
    new GifEncoder(image, out, true).encode();

    out.close();
}
} 

Error:

type Exception report
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.NoClassDefFoundError: Acme/JPM/Encoders/GifEncoder
imageChecker.ImageServlet.doPost(ImageServlet.java:30)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

How to solve this error I placed acme.jar in build path Thanks in advance

Nishant Gupta
  • 3,533
  • 1
  • 11
  • 18
Rajat.r2
  • 137
  • 2
  • 13

1 Answers1

0

After read some blog about servlet I found the solution

Just put acme.jar and all other jar file inside the WebContent ->WEB-INF ->lib directory and build project I don't know till now why build path jar file not work for in this scenario.

Rajat.r2
  • 137
  • 2
  • 13