Skip to content

Instantly share code, notes, and snippets.

@gscordeiro
Created November 29, 2012 17:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gscordeiro/4170587 to your computer and use it in GitHub Desktop.
Save gscordeiro/4170587 to your computer and use it in GitHub Desktop.
Servlet para carregar imagem
@WebServlet(urlPatterns="/carrega-imagem")
public class ImagemServlet extends HttpServlet{
private static final long serialVersionUID = -4433688269834762430L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String id = req.getParameter("auto_id");
Automovel automovel = JpaUtil.getEntityManager().find(Automovel.class, Long.valueOf(id));
if(!automovel.getFotos().isEmpty()){
resp.getOutputStream().write(automovel.getFotos().get(0).getContent());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment