Package it.hotel.controller.image

Source Code of it.hotel.controller.image.ImageDownloadController

/*
Copyright (C) European Community 2008 - Licensed under the EUPL V.1.0 (http://ec.europa.eu/idabc/en/document/6523)
*/

package it.hotel.controller.image;

import it.hotel.model.structure.Structure;
import it.hotel.model.structure.manager.IStructureManager;

import java.io.OutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;


/**
*
*
*/
public class ImageDownloadController implements Controller {
 
  private IStructureManager structureManager;

  /**
   * @throws
   * @return
   */
  @Override
  public ModelAndView handleRequest(HttpServletRequest req,
      HttpServletResponse res) throws Exception {
    String id = req.getParameter("id");
    String type = req.getParameter("type");
    try {
      byte[] image = null;
      if("hotel".equals(type)){
        Structure structure = (Structure) structureManager.get(Integer.parseInt(id));
        image = structure.getImage();
      }
      OutputStream out= res.getOutputStream();
      out.write(image)
      out.close();
     
    } catch (Exception e) {
    }

    return null;
  }

  public void setStructureManager(IStructureManager structureManager) {
    this.structureManager = structureManager;
  }
 

 
 
}
TOP

Related Classes of it.hotel.controller.image.ImageDownloadController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.