Example usage for javax.servlet.http HttpServletRequest setCharacterEncoding

List of usage examples for javax.servlet.http HttpServletRequest setCharacterEncoding

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest setCharacterEncoding.

Prototype

public void setCharacterEncoding(String env) throws UnsupportedEncodingException;

Source Link

Document

Overrides the name of the character encoding used in the body of this request.

Usage

From source file:com.megaeyes.web.controller.VISController.java

@ControllerDescription(description = "??", isLog = false, isCheckSession = true)
@RequestMapping("/listVideoInputServerByOrganId.json")
public void listVideoInputServerByOrganId(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    GetVideoInputServerResponse resp = new GetVideoInputServerResponse();
    String start = (String) request.getAttribute("start");
    String limit = (String) request.getAttribute("limit");
    String name = (String) request.getAttribute("name");
    String address = (String) request.getAttribute("address");
    String ip = (String) request.getAttribute("ip");
    String deviceNumber = (String) request.getAttribute("deviceNumber");
    String lineBackFew = (String) request.getAttribute("lineBackFew");
    String towerNumber = (String) request.getAttribute("towerNumber");
    String switchesIp = (String) request.getAttribute("switchesIp");
    String serialServerIp = (String) request.getAttribute("serialServerIp");
    String voltageLevel = (String) request.getAttribute("voltageLevel");
    String areaBelongs = (String) request.getAttribute("areaBelongs");
    String type = (String) request.getAttribute("type");
    if (StringUtils.isBlank(deviceNumber))
        deviceNumber = null;/*from  w w w  .  j a v a  2  s. co  m*/
    String organId = (String) request.getAttribute("organId");
    try {
        List vis = vISManager.getVISByOrganId(start, limit, name, address, deviceNumber, lineBackFew,
                towerNumber, switchesIp, serialServerIp, voltageLevel, areaBelongs, type, organId);
        int count = vISManager.getVISByOrganIdCount(name, address, deviceNumber, lineBackFew, towerNumber,
                switchesIp, serialServerIp, voltageLevel, areaBelongs, type, organId);
        resp.setVis(vis);
        resp.setTotalCount(count + "");
    } catch (BusinessException be) {
        resp.setCode(be.getCode());
        resp.setMessage(be.getMessage());
    }
    writePageNoZip(response, resp);

}

From source file:com.megaeyes.web.controller.VISController.java

@ControllerDescription(description = "??", isLog = false, isCheckSession = true)
@RequestMapping("/updateGVIC.json")
public void updateVic(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    BaseResponse resp = new BaseResponse();
    String id = (String) request.getAttribute("id");
    String visID = (String) request.getAttribute("visId");
    String name = (String) request.getAttribute("name");
    String installLocation = (String) request.getAttribute("location");
    String hasPan = (String) request.getAttribute("hasPan");
    String channelId = (String) request.getAttribute("channelId");
    String storageType = (String) request.getAttribute("storageType");
    String storageServer = (String) request.getAttribute("storageServer");
    String dispatchServer = (String) request.getAttribute("dispatchServer");
    String note = (String) request.getAttribute("note");
    String isSuspended = (String) request.getAttribute("isSuspended");
    String organId = (String) request.getAttribute("organId");
    String isShare = (String) request.getAttribute("isShare");
    String sipCode = (String) request.getAttribute("sipCode");
    String longitude = (String) request.getAttribute("longitude");
    String latitude = (String) request.getAttribute("latitude");
    // ID/*www.  ja va 2 s.co m*/
    String assId = (String) request.getAttribute("assId");
    if (resp.getCode().equals(ErrorCode.SUCCESS)) {
        try {
            vISManager.updateVic(id, name, installLocation, hasPan, channelId, storageType, storageServer,
                    dispatchServer, note, isSuspended, organId, visID, isShare, sipCode, longitude, latitude,
                    assId);
            resp.setCode(ErrorCode.SUCCESS);
        } catch (BusinessException be) {
            resp.setCode(be.getCode());
            resp.setMessage(be.getMessage());
        }
        writePageNoZip(response, resp);
    }
}

From source file:com.megaeyes.web.controller.VISController.java

@ControllerDescription(description = "", isLog = true, isCheckSession = true)
@RequestMapping("/createAIC.json")
public void createAIC(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    BaseResponse resp = new BaseResponse();
    String name = (String) request.getAttribute("name");
    String visId = (String) request.getAttribute("visId");
    String typeId = (String) request.getAttribute("typeId");
    String location = (String) request.getAttribute("location");
    String note = (String) request.getAttribute("note");
    String organId = (String) request.getAttribute("organId");
    String epDeviceType = (String) request.getAttribute("epDeviceType");
    String sipCode = (String) request.getAttribute("sipCode");
    String longitude = (String) request.getAttribute("longitude");
    String latitude = (String) request.getAttribute("latitude");
    String channelId = (String) request.getAttribute("channelId");
    String isShare = request.getParameter("isShare");
    if (StringUtils.isBlank(isShare)) {
        resp.setCode(ErrorCode.PARAMETER_NOT_FOUND);
        resp.setMessage("isShare");
    }//  w ww  .  j av  a  2s.  c  o  m
    // ?
    if (resp.getCode().equals(ErrorCode.SUCCESS)) {
        try {
            String id = vISManager.createAIC(visId, name, typeId, location, note, organId, epDeviceType,
                    sipCode, longitude, latitude, channelId, isShare);
            resp.setMessage(id);
            resp.setCode(ErrorCode.SUCCESS);
        } catch (BusinessException be) {
            resp.setCode(be.getCode());
            resp.setMessage(be.getMessage());
        }
    }

    writePageNoZip(response, resp);
}

From source file:com.megaeyes.web.controller.VISController.java

@ControllerDescription(description = "?", isLog = true, isCheckSession = true)
@RequestMapping("/createGVIC.json")
public void createvic(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    BaseResponse resp = new BaseResponse();
    // ?License//from   www  .ja v  a  2s  .c  o m
    resp.setCode(checkVicLicence());

    String visId = (String) request.getAttribute("visId");
    String name = (String) request.getAttribute("name");
    String installLocation = (String) request.getAttribute("location");
    String channelId = (String) request.getAttribute("channelId");
    if (StringUtils.isBlank(channelId)) {
        channelId = "1";
    }
    String hasPan = (String) request.getAttribute("hasPan");
    String storageType = (String) request.getAttribute("storageType");
    String storageServer = (String) request.getAttribute("storageServer");
    String dispatchServer = (String) request.getAttribute("dispatchServer");
    String note = (String) request.getAttribute("note");
    String isSuspended = (String) request.getAttribute("isSuspended");
    String organId = (String) request.getAttribute("organId");
    String epDeviceType = (String) request.getAttribute("epDeviceType");
    String isShare = (String) request.getAttribute("isShare");
    String sipCode = (String) request.getAttribute("sipCode");
    String longitude = (String) request.getAttribute("longitude");
    String latitude = (String) request.getAttribute("latitude");
    // ID
    String assId = (String) request.getAttribute("assId");
    if (resp.getCode().equals(ErrorCode.SUCCESS)) {
        try {
            String id = vISManager.createVic(visId, name, installLocation, channelId, hasPan, storageType,
                    storageServer, dispatchServer, note, isSuspended, organId, epDeviceType, isShare, sipCode,
                    longitude, latitude, assId);
            resp.setMessage(id);
        } catch (BusinessException be) {
            resp.setCode(be.getCode());
            resp.setMessage(be.getMessage());
        }
    }
    writePageNoZip(response, resp);
}

From source file:com.megaeyes.web.controller.VISController.java

@ControllerDescription(description = "IP?", isLog = true, isCheckSession = true)
@RequestMapping("/createIpVic.json")
public void createIpVic(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    BaseResponse resp = new BaseResponse();
    // ?License/*www  .ja v a  2  s.  c om*/
    resp.setCode(checkVicLicence());

    String visId = (String) request.getAttribute("visId");
    String name = (String) request.getAttribute("name");
    String installLocation = (String) request.getAttribute("location");
    String password = (String) request.getAttribute("password");
    String hasPan = (String) request.getAttribute("hasPan");
    String host = (String) request.getAttribute("host");
    String port = (String) request.getAttribute("port");
    if (StringUtils.isBlank(port)) {
        port = "80";
    }
    String storageType = (String) request.getAttribute("storageType");
    String storageServer = (String) request.getAttribute("storageServer");
    String dispatchServer = (String) request.getAttribute("dispatchServer");
    String organId = (String) request.getAttribute("organId");
    String isShare = (String) request.getAttribute("isShare");
    String sipCode = (String) request.getAttribute("sipCode");
    String longitude = (String) request.getAttribute("longitude");
    String latitude = (String) request.getAttribute("latitude");
    String alarmStorageServerId = (String) request.getAttribute("alarmStorageServerId");
    String note = (String) request.getAttribute("note");
    if (resp.getCode().equals(ErrorCode.SUCCESS)) {
        try {
            String id = vISManager.createIpVic(visId, name, installLocation, password, hasPan, host, port,
                    storageType, storageServer, dispatchServer, organId, isShare, sipCode, longitude, latitude,
                    alarmStorageServerId, note);
            resp.setCode(ErrorCode.SUCCESS);
            resp.setMessage(id);
        } catch (BusinessException be) {
            resp.setCode(be.getCode());
            resp.setMessage(be.getMessage());
        }
        writePageNoZip(response, resp);
    }
}

From source file:com.jkkp.modules.supplier.controller.SupplierController.java

@RequestMapping(value = "/save.do")
public String save(HttpServletRequest req, Integer regionId, String spName, String contactUser,
        String contactMobile, String legalPerson, Float gainRate, String address, Integer type, Integer levelId,
        Integer levelMoney, String bindMobile) {
    try {/*from ww  w.  j a v a 2 s . c o  m*/
        req.setCharacterEncoding("utf-8");
        String abbreviation = req.getParameter("abbreviation");
        System.out.println("save legalPerson=" + legalPerson);

        //?
        Supplier supplier = new Supplier();
        supplier.setAbbreviation(abbreviation);
        //supplier.setCityDomain(cityDomain);
        supplier.setSpName(spName);
        supplier.setContactUser(contactUser);
        supplier.setLegalPerson(legalPerson);
        supplier.setContactMobile(contactMobile);
        supplier.setGainRate(gainRate / 100);
        //         supplier.setStartDate(startDate);
        //         supplier.setEndDate(endDate);
        supplier.setAddress(address);
        supplier.setType(type);
        supplier.setBindMobile(bindMobile);
        supplier.setLevelId(levelId);
        supplier.setRegionId(regionId);
        if (levelId != null && levelId == 0) {
            List<SupplierLevel> levelMoneyList = supplierLevelService.selectByProperty("levelMoney",
                    levelMoney);
            if (levelMoneyList.size() > 0) {
                supplier.setLevelId(levelMoneyList.get(0).getId());
            } else {
                SupplierLevel supplierLevel = supplierLevelService.saveOne(levelMoney);
                supplier.setLevelId(supplierLevel.getId());
            }
        }
        supplierService.saveOrUpdate(supplier);
        String params = RequestParamUtils.joinRedirectParams(req, new String[] { "mid", "pid" });
        return "redirect:index.xhtml" + params;
    } catch (Exception e) {
        logger.error("", e);
        return "404";
    }

}

From source file:com.megaeyes.web.controller.VISController.java

@ControllerDescription(description = "IP?", isLog = true, isCheckSession = true)
@RequestMapping("/updateIpVic.json")
public void updateIpVic(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    BaseResponse resp = new BaseResponse();
    String id = (String) request.getAttribute("id");
    if (StringUtils.isBlank(id)) {
        resp.setCode(ErrorCode.PARAMETER_NOT_FOUND);
        resp.setMessage("id");
    }//from w  w w .jav a2  s  .c o  m
    String name = (String) request.getAttribute("name");
    String installLocation = (String) request.getAttribute("location");
    String password = (String) request.getAttribute("password");
    String hasPan = (String) request.getAttribute("hasPan");
    String host = (String) request.getAttribute("host");
    String port = (String) request.getAttribute("port");
    if (StringUtils.isBlank(port)) {
        port = "80";
    }
    String storageType = (String) request.getAttribute("storageType");
    String channelId = (String) request.getAttribute("channelId");
    String storageServer = (String) request.getAttribute("storageServer");
    String dispatchServer = (String) request.getAttribute("dispatchServer");
    String note = (String) request.getAttribute("note");
    String organId = (String) request.getAttribute("organId");
    String isShare = (String) request.getAttribute("isShare");
    // String epDeviceType = (String) request.getAttribute("epDeviceType");
    String sipCode = (String) request.getAttribute("sipCode");
    String longitude = (String) request.getAttribute("longitude");
    String latitude = (String) request.getAttribute("latitude");
    String alarmStorageServerId = (String) request.getAttribute("alarmStorageServerId");
    if (resp.getCode().equals(ErrorCode.SUCCESS)) {
        try {
            vISManager.updateIpVic(id, name, installLocation, password, hasPan, host, port, storageType,
                    storageServer, dispatchServer, organId, isShare, sipCode, longitude, latitude, note,
                    channelId, alarmStorageServerId);
            resp.setCode(ErrorCode.SUCCESS);
        } catch (BusinessException be) {
            resp.setCode(be.getCode());
            resp.setMessage(be.getMessage());
        }
    }

    writePageNoZip(response, resp);
}

From source file:com.megaeyes.web.controller.VISController.java

@ControllerDescription(description = "?ID", isLog = false, isCheckSession = true)
@RequestMapping("/listAOCByOrganId.json")
public void listAOCByOrganId(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    ListAlarmOutputChannelResponse resp = new ListAlarmOutputChannelResponse();
    resp.setCode(ErrorCode.SUCCESS);//from ww  w . ja v a  2  s  .co  m
    String organId = (String) request.getAttribute("organId");
    if (StringUtils.isBlank(organId)) {
        resp.setCode(ErrorCode.PARAMETER_NOT_FOUND);
        resp.setMessage("organId");
    }
    int start = 0;
    int length = 26;
    String sStart = (String) request.getAttribute("start");
    if (StringUtils.isNotBlank(sStart)) {
        try {
            start = Integer.parseInt(sStart);
        } catch (NumberFormatException e) {
            resp.setCode(ErrorCode.PARAMETER_VALUE_INVALIDED + "");
            resp.setMessage("start");
        }
    }
    String limit = (String) request.getAttribute("limit");
    String name = (String) request.getAttribute("name");
    if (StringUtils.isNotBlank(limit)) {
        try {
            length = Integer.parseInt(limit);
        } catch (NumberFormatException e) {
            resp.setCode(ErrorCode.PARAMETER_VALUE_INVALIDED + "");
            resp.setMessage("limit");
        }
    }
    if (resp.getCode().equals(ErrorCode.SUCCESS)) {
        try {
            Map<Object, Object> queryMap = new HashMap<Object, Object>();
            queryMap.put("organId", organId);
            queryMap.put("start", start);
            queryMap.put("limit", length);
            queryMap.put("name", name);
            List<AlarmOutputChannel> aocs = vISManager.listAOCByOrganId(queryMap);
            resp.setAocs(aocs);
            resp.setCode(ErrorCode.SUCCESS);
        } catch (BusinessException be) {
            resp.setCode(be.getCode());
            resp.setMessage(be.getMessage());
        }
    }
    writePageNoZip(response, resp);
}

From source file:com.devpia.service.DEXTUploadJController.java

@RequestMapping(value = "/dextfile/downloadFile.do", method = RequestMethod.GET)
//   public ModelAndView downloadFile2(@RequestParam("changeInfoId") String changeInfoId, @RequestParam("idx") String idx
public void downloadFile2(HttpServletRequest req, HttpServletResponse res, ModelMap model,
        @RequestParam("filePath") String filePath, @RequestParam("filename") String filename,
        @RequestParam Map<String, Object> map)
        //   public void downloadFile2( HttpServletRequest req, HttpServletResponse res, ModelMap model)
        throws Exception {
    req.setCharacterEncoding("utf-8");
    res.setCharacterEncoding("utf-8");
    //System.err.println(new String(req.getParameter("filePath").getBytes("8859_1"), "utf-8") ); //2
    //       /*  w  w w .j av  a  2s .  c  o m*/
    //       String filePath = URLDecoder.decode(req.getParameter("filePath"), "UTF-8");
    //       String filename = URLDecoder.decode(req.getParameter("filename"), "UTF-8");

    //      String repositoryPath = propertyService.getString("Globals.folderStorePath")+File.separatorChar+changeInfoId+File.separatorChar+idx;
    String repositoryPath = StringUtils.replace(
            propertyService.getString("Globals.folderStorePath") + filePath + filename, "__",
            File.separatorChar + "");
    //System.err.println(repositoryPath);
    //       File repository = new File(repositoryPath);

    //      Collection<File> list = FileUtils.listFiles(repository, FileFilterUtils.fileFileFilter(), DirectoryFileFilter.INSTANCE);

    //      ModelAndView mav = new ModelAndView("downloadView");
    //      mav.addObject("downloadFile", new File(repositoryPath));
    //      mav.addObject("fileName", filename);
    //      return mav;
    FileDownload dextj = new FileDownload(req, res);
    File target = new File(repositoryPath);
    if (target.exists()) {
        dextj.Download(target.getAbsolutePath(), true, false);
    } else {
        res.sendError(404, filename.concat(" not found"));
    }
}

From source file:com.hp.action.ProductsAction.java

public String updateProduct() throws UnsupportedEncodingException {
    HttpServletRequest request = (HttpServletRequest) ActionContext.getContext()
            .get(ServletActionContext.HTTP_REQUEST);
    HttpSession session = request.getSession();

    //Authorize/*w  w  w .j a  va 2 s .  c om*/
    if (!userDAO.authorize((String) session.getAttribute("user_name"),
            (String) session.getAttribute("user_password"))) {
        return LOGIN;
    }

    request.setCharacterEncoding("UTF8");
    providerIDList = providerDAO.getProvidersIDList();

    System.out.println("id_product: " + product.getSerial() + " ma vach: " + product.getBarcode() + " vat= "
            + request.getParameter("product.vatTax"));

    //update price
    product.setExportPrices(product.getImportPrices() + product.getImportPrices() * product.getVatTax() / 100);

    //new product
    if (product.getSerial() <= 0) {

        System.out.println("OKsave" + product.getProductID());
        boolean status = productDAO.saveOrUpdate(product);
        productsList = productDAO.getProductList();

        if (status) {
            return SUCCESS;
        }
        return INPUT;
    } else {
        System.out.println("OK" + product.getProductID());

        boolean status = productDAO.update(product);
        productsList = productDAO.getProductList();

        if (status) {

            return SUCCESS;
        }

        return INPUT;
    }
}