Example usage for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR

List of usage examples for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR.

Prototype

int SC_INTERNAL_SERVER_ERROR

To view the source code for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR.

Click Source Link

Document

Status code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.

Usage

From source file:org.sventon.web.ctrl.RSSController.java

private void handleError(HttpServletResponse response, String errorMessage) throws IOException {
    logger.error(errorMessage);/* w  w w  .jav  a 2s.  c om*/
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errorMessage);
}

From source file:org.jasig.portlet.announcements.controller.RssFeedController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws IllegalStateException, IOException {

    response.setContentType(CONTENT_TYPE);

    Long topicId;// w w  w.  j ava2s.com
    try {
        topicId = Long.valueOf(ServletRequestUtils.getIntParameter(request, "topic"));
        if (topicId == null) {
            throw new IllegalStateException("Must specify the topic id");
        }
    } catch (Exception e) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Must specify topic id");
        return null;
    }

    Topic t = null;
    try {
        t = announcementService.getTopic(topicId);
    } catch (PortletException e) {
        e.printStackTrace();
    }

    if (t == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "no such topic");
        return null;
    }

    if (!t.isAllowRss()) {
        response.sendError(HttpServletResponse.SC_FORBIDDEN, "This topic is not available as RSS");
        return null;
    }

    // fetch and sort the announcements
    List<Announcement> announcements = new ArrayList<Announcement>();
    announcements.addAll(t.getPublishedAnnouncements());

    Collections.sort(announcements);

    // create the feed
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setTitle(t.getTitle());
    feed.setLink(request.getRequestURL().append("?topic=").append(topicId.toString()).toString());
    feed.setDescription(t.getDescription());

    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    SyndEntry entry;
    SyndContent description;

    for (Announcement a : announcements) {
        entry = new SyndEntryImpl();
        entry.setTitle(a.getTitle());
        entry.setAuthor(a.getAuthor());
        if (a.getLink() != null)
            entry.setLink(a.getLink());
        entry.setPublishedDate(a.getStartDisplay());
        description = new SyndContentImpl();
        description.setType("text/plain");
        description.setValue(a.getMessage());
        entry.setDescription(description);
        entries.add(entry);
    }

    feed.setEntries(entries);

    SyndFeedOutput output = new SyndFeedOutput();
    String out;
    try {
        out = output.outputString(feed);
    } catch (FeedException e) {
        e.printStackTrace();
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error generating feed");
        return null;
    }

    response.setContentLength(out.length());
    response.getOutputStream().print(out);
    response.getOutputStream().flush();

    return null;

}

From source file:org.jetbrains.webdemo.handlers.ServerHandler.java

public void handle(final HttpServletRequest request, final HttpServletResponse response) throws IOException {

    if (request.getQueryString() != null && request.getQueryString().equals("test")) {
        try (PrintWriter out = response.getWriter()) {
            out.write("ok");
        } catch (Throwable e) {
            ErrorWriter.ERROR_WRITER.writeExceptionToExceptionAnalyzer(e, "TEST", request.getHeader("Origin"),
                    "null");
        }//from w w w. j a v  a2  s . c  om
    } else {
        SessionInfo sessionInfo;
        if (CommonSettings.IS_TEST_VERSION) {
            response.setHeader("Access-Control-Allow-Origin", "*");
        } else {
            response.setHeader("Access-Control-Allow-Origin",
                    "http://staging.kotlinlang.org.s3-website-eu-west-1.amazonaws.com");
        }
        try {
            switch (request.getParameter("type")) {
            case ("getUserName"):
                sessionInfo = setSessionInfo(request.getSession(), request.getHeader("Origin"));
                sendUserName(request, response, sessionInfo);
                break;
            case ("sendMail"):
                sessionInfo = setSessionInfo(request.getSession(), request.getHeader("Origin"));
                sessionInfo.setType(SessionInfo.TypeOfRequest.SEND_MAIL);
                sendMail(request, response, sessionInfo);
                break;
            case ("loadHelpForWords"):
                sendHelpContentForWords(request, response);
                break;
            case ("getKotlinVersions"):
                sendKotlinVersions(request, response);
                break;
            case ("run"):
                forwardRunRequest(request, response);
                break;
            case ("highlight"):
                forwardHighlightRequest(request, response);
                break;
            case ("complete"):
                forwardCompleteRequest(request, response);
                break;
            case ("convertToKotlin"):
                forwardConvertResult(request, response);
                break;
            default: {
                sessionInfo = setSessionInfo(request.getSession(), request.getHeader("Origin"));
                MyHttpSession session = new MyHttpSession(sessionInfo);
                session.handle(request, response);
            }
            }
        } catch (Throwable e) {
            //Do not stop server
            ErrorWriter.ERROR_WRITER.writeExceptionToExceptionAnalyzer(e, "UNKNOWN", "unknown",
                    request.getRequestURI() + "?" + request.getQueryString());
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    }
}

From source file:net.myrrix.web.servlets.IngestServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    MyrrixRecommender recommender = getRecommender();

    boolean fromBrowserUpload = request.getContentType().startsWith("multipart/form-data");

    Reader reader;//from w  ww  . ja  v  a  2s  .c  om
    if (fromBrowserUpload) {

        Collection<Part> parts = request.getParts();
        if (parts == null || parts.isEmpty()) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No form data");
            return;
        }
        Part part = parts.iterator().next();
        String partContentType = part.getContentType();
        InputStream in = part.getInputStream();
        if ("application/zip".equals(partContentType)) {
            in = new ZipInputStream(in);
        } else if ("application/gzip".equals(partContentType)) {
            in = new GZIPInputStream(in);
        } else if ("application/x-gzip".equals(partContentType)) {
            in = new GZIPInputStream(in);
        } else if ("application/bzip2".equals(partContentType)) {
            in = new BZip2CompressorInputStream(in);
        } else if ("application/x-bzip2".equals(partContentType)) {
            in = new BZip2CompressorInputStream(in);
        }
        reader = new InputStreamReader(in, Charsets.UTF_8);

    } else {

        String charEncodingName = request.getCharacterEncoding();
        Charset charEncoding = charEncodingName == null ? Charsets.UTF_8 : Charset.forName(charEncodingName);
        String contentEncoding = request.getHeader(HttpHeaders.CONTENT_ENCODING);
        if (contentEncoding == null) {
            reader = request.getReader();
        } else if ("gzip".equals(contentEncoding)) {
            reader = new InputStreamReader(new GZIPInputStream(request.getInputStream()), charEncoding);
        } else if ("zip".equals(contentEncoding)) {
            reader = new InputStreamReader(new ZipInputStream(request.getInputStream()), charEncoding);
        } else if ("bzip2".equals(contentEncoding)) {
            reader = new InputStreamReader(new BZip2CompressorInputStream(request.getInputStream()),
                    charEncoding);
        } else {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unsupported Content-Encoding");
            return;
        }

    }

    try {
        recommender.ingest(reader);
    } catch (IllegalArgumentException iae) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.toString());
        return;
    } catch (NoSuchElementException nsee) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString());
        return;
    } catch (TasteException te) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString());
        getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te);
        return;
    }

    String referer = request.getHeader(HttpHeaders.REFERER);
    if (fromBrowserUpload && referer != null) {
        // Parsing avoids response splitting
        response.sendRedirect(new URL(referer).toString());
    }

}

From source file:com.themodernway.server.core.servlet.ContentUploadServlet.java

@Override
public void doPost(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {
    try {//from   w  ww. j av  a 2  s.c om
        final IFolderItem fold = getRoot();

        if (null == fold) {
            if (logger().isErrorEnabled()) {
                logger().error(LoggingOps.THE_MODERN_WAY_MARKER, "Can't find storage root.");
            }
            sendErrorCode(request, response, HttpServletResponse.SC_NOT_FOUND);

            return;
        }
        if (false == fold.isWritable()) {
            if (logger().isErrorEnabled()) {
                logger().error(LoggingOps.THE_MODERN_WAY_MARKER, "Can't write storage root.");
            }
            sendErrorCode(request, response, HttpServletResponse.SC_NOT_FOUND);

            return;
        }
        final String path = getPathNormalized(toTrimOrElse(request.getPathInfo(), FileUtils.SINGLE_SLASH));

        if (null == path) {
            if (logger().isErrorEnabled()) {
                logger().error(LoggingOps.THE_MODERN_WAY_MARKER, "Can't find path info.");
            }
            sendErrorCode(request, response, HttpServletResponse.SC_NOT_FOUND);

            return;
        }
        final ServletFileUpload upload = new ServletFileUpload(getDiskFileItemFactory());

        upload.setSizeMax(getFileSizeLimit());

        final List<FileItem> items = upload.parseRequest(request);

        for (final FileItem item : items) {
            if (false == item.isFormField()) {
                if (item.getSize() > fold.getFileSizeLimit()) {
                    item.delete();

                    if (logger().isErrorEnabled()) {
                        logger().error(LoggingOps.THE_MODERN_WAY_MARKER, "File size exceeds limit.");
                    }
                    sendErrorCode(request, response, HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);

                    return;
                }
                final IFileItem file = fold.file(FileUtils.concat(path, item.getName()));

                if (null != file) {
                    try (InputStream read = item.getInputStream()) {
                        fold.create(file.getPath(), read);
                    } catch (final IOException e) {
                        item.delete();

                        final IServletExceptionHandler handler = getServletExceptionHandler();

                        if ((null == handler) || (false == handler.handle(request, response,
                                getServletResponseErrorCodeManagerOrDefault(), e))) {
                            if (logger().isErrorEnabled()) {
                                logger().error(LoggingOps.THE_MODERN_WAY_MARKER, "Can't write file.", e);
                            }
                            sendErrorCode(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                        }
                        return;
                    }
                } else {
                    item.delete();

                    if (logger().isErrorEnabled()) {
                        logger().error(LoggingOps.THE_MODERN_WAY_MARKER, "Can't find file.");
                    }
                    sendErrorCode(request, response, HttpServletResponse.SC_NOT_FOUND);

                    return;
                }
            }
            item.delete();
        }
    } catch (IOException | FileUploadException e) {
        final IServletExceptionHandler handler = getServletExceptionHandler();

        if ((null == handler) || (false == handler.handle(request, response,
                getServletResponseErrorCodeManagerOrDefault(), e))) {
            if (logger().isErrorEnabled()) {
                logger().error(LoggingOps.THE_MODERN_WAY_MARKER, "captured overall exception for security.", e);
            }
            sendErrorCode(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    }
}

From source file:nl.surfnet.mujina.spring.SAMLAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {

    AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(),
            timeService, idService);//from  www.j a  v  a  2  s .com
    EndpointGenerator endpointGenerator = new EndpointGenerator();

    String singleSignOnServiceURL = spConfiguration.getSingleSignOnServiceURL();

    singleSignOnServiceURL = transparentProxying(request, singleSignOnServiceURL);

    String localAssertionConsumerServiceURL = spConfiguration.getAssertionConsumerServiceURL();

    Endpoint endpoint = endpointGenerator.generateEndpoint(SingleSignOnService.DEFAULT_ELEMENT_NAME,
            singleSignOnServiceURL, localAssertionConsumerServiceURL);

    AuthnRequest authnReqeust = authnRequestGenerator.generateAuthnRequest(singleSignOnServiceURL,
            localAssertionConsumerServiceURL, spConfiguration.getProtocolBinding());

    log.debug("Sending authnRequest to {}", singleSignOnServiceURL);

    try {
        CriteriaSet criteriaSet = new CriteriaSet();
        criteriaSet.add(new EntityIDCriteria(spConfiguration.getEntityID()));
        criteriaSet.add(new UsageCriteria(UsageType.SIGNING));

        Credential signingCredential = credentialResolver.resolveSingle(criteriaSet);
        Validate.notNull(signingCredential);

        String relayState = null; // Not needed here.

        bindingAdapter.sendSAMLMessage(authnReqeust, endpoint, response, relayState, signingCredential);
    } catch (MessageEncodingException mee) {
        log.error("Could not send authnRequest to Identity Provider.", mee);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (org.opensaml.xml.security.SecurityException e) {
        log.error("Unable to retrieve signing credential", e);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}

From source file:com.alfaariss.oa.ManagerServlet.java

/**
 * Handles requests send by the system manager.
 * /*from  w w w. j a  v a  2 s  .c om*/
 * The following requests are supported at this moment:
 * <ul>
 * <li>do=restart</li>
 * <li>do=stop</li>
 * <li>do=start</li>
 * </ul>
 * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public void service(HttpServletRequest oRequest, HttpServletResponse oResponse)
        throws ServletException, IOException {
    try {
        Properties pConfig = cloneConfigurationFromRequest(oRequest);
        String sDo = oRequest.getParameter("do");
        if (sDo == null) //No 'do' paramater
        {
            String sGet = oRequest.getParameter("get");
            if (sGet == null) //No 'get' and no 'do' paramater
            {
                _logger.error("Invalid request sent from IP: " + oRequest.getRemoteAddr());
                oResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
            } else {
                StringBuffer sbWarning = new StringBuffer("Invalid request with name: ");
                sbWarning.append(sGet);
                sbWarning.append(", sent from IP: ");
                sbWarning.append(oRequest.getRemoteAddr());
                _logger.error(sbWarning.toString());
                oResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
            }

        } else if (sDo.equals("restart")) {
            _logger.info("Performing restart request sent from IP: " + oRequest.getRemoteAddr());
            _oEngineLauncher.restart(pConfig);
        } else if (sDo.equals("stop")) {
            _logger.info("Performing stop request sent from IP: " + oRequest.getRemoteAddr());
            _oEngineLauncher.stop();
        } else if (sDo.equals("start")) {
            _logger.info("Performing start request sent from IP: " + oRequest.getRemoteAddr());
            _oEngineLauncher.start(pConfig);
        } else {
            StringBuffer sbWarning = new StringBuffer("Invalid request with name: ");
            sbWarning.append(sDo);
            sbWarning.append(", sent from IP: ");
            sbWarning.append(oRequest.getRemoteAddr());
            _logger.error(sbWarning.toString());
            oResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
        }

        if (!oResponse.isCommitted())
            oResponse.sendError(HttpServletResponse.SC_OK);
    } catch (OAException e) {
        _logger.error("Error processing request", e);

        _logger.debug("try stopping the server");
        _oEngineLauncher.stop();

        if (!oResponse.isCommitted())
            oResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (Exception e) {
        _logger.fatal("Internal error", e);

        _logger.debug("try stopping the server");
        _oEngineLauncher.stop();

        if (!oResponse.isCommitted())
            oResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}

From source file:eu.trentorise.smartcampus.unidataservice.controller.rest.StudentInfoController.java

@RequestMapping(method = RequestMethod.GET, value = "/getstudentdata/{userId}")
public @ResponseBody StudentInfoData getStudentInfo(HttpServletRequest request, HttpServletResponse response,
        @PathVariable String userId) throws InvocationException {
    try {/*from www  . ja  v a 2 s . c o  m*/
        User user = getUserObject(userId);
        if (user == null) {
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            return null;
        }

        String token = getToken(request);
        String idAda = getIdAda(userId, token);
        StudentInfoData sd = getStudentInfo(idAda);
        if (sd != null) {
            return sd;
        } else {
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        }

        return null;
    } catch (Exception e) {
        e.printStackTrace();
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    return null;
}

From source file:at.gv.egiz.bku.online.webapp.UIServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    BindingProcessorManager bindingProcessorManager = (BindingProcessorManager) getServletContext()
            .getAttribute("bindingProcessorManager");
    if (bindingProcessorManager == null) {
        String msg = "Configuration error: BindingProcessorManager missing!";
        log.error(msg);/* w  w w  .  ja v a  2s  .  co  m*/
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
        return;
    }

    Configuration conf = ((BindingProcessorManagerImpl) bindingProcessorManager).getConfiguration();
    if (conf == null)
        log.error("No configuration");
    else
        MoccaParameterBean.setP3PHeader(conf, resp);

    super.doPost(req, resp);
}

From source file:org.opendatakit.aggregate.servlet.GetActiveUsersServlet.java

/**
 * Handler for HTTP Get request that returns the list of roles assigned to this user.
 * // ww  w  .  java  2  s.com
 * Assumed to return a entity body that is a JSON serialization of a list.
 *
 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 */
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    CallingContext cc = ContextFactory.getCallingContext(this, req);

    TreeSet<GrantedAuthorityName> grants;
    try {
        grants = SecurityServiceUtil.getCurrentUserSecurityInfo(cc);
    } catch (ODKDatastoreException e) {
        logger.error("Retrieving users persistence error: " + e.toString());
        e.printStackTrace();
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                ErrorConsts.PERSISTENCE_LAYER_PROBLEM + "\n" + e.toString());
        return;
    }

    boolean returnFullList = false;
    for (GrantedAuthorityName grant : grants) {
        if (grant.equals(GrantedAuthorityName.ROLE_SITE_ACCESS_ADMIN)
                || grant.equals(GrantedAuthorityName.ROLE_ADMINISTER_TABLES)
                || grant.equals(GrantedAuthorityName.ROLE_SUPER_USER_TABLES)) {
            returnFullList = true;
            break;
        }
    }

    // returned object (will be JSON serialized).
    ArrayList<HashMap<String, Object>> listOfUsers = new ArrayList<HashMap<String, Object>>();

    HashMap<String, Object> hashMap;
    if (!returnFullList) {
        // only return ourself -- we don't have privileges to see everyone
        hashMap = new HashMap<String, Object>();
        User user = cc.getCurrentUser();
        if (user.isAnonymous()) {
            hashMap.put(USER_ID, "anonymous");
            hashMap.put(FULL_NAME, User.ANONYMOUS_USER_NICKNAME);
        } else {
            RegisteredUsersTable entry;
            try {
                entry = RegisteredUsersTable.getUserByUri(user.getUriUser(), cc.getDatastore(),
                        cc.getCurrentUser());
            } catch (ODKDatastoreException e) {
                logger.error("Retrieving users persistence error: " + e.toString());
                e.printStackTrace();
                resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        ErrorConsts.PERSISTENCE_LAYER_PROBLEM + "\n" + e.toString());
                return;
            }
            if (user.getEmail() == null) {
                hashMap.put(USER_ID, "username:" + entry.getUsername());
                if (user.getNickname() == null) {
                    hashMap.put(FULL_NAME, entry.getUsername());
                } else {
                    hashMap.put(FULL_NAME, user.getNickname());
                }
            } else {
                hashMap.put(USER_ID, entry.getEmail());
                if (user.getNickname() == null) {
                    hashMap.put(FULL_NAME, entry.getEmail().substring(EmailParser.K_MAILTO.length()));
                } else {
                    hashMap.put(FULL_NAME, user.getNickname());
                }
            }
        }
        processRoles(grants, hashMap);
        listOfUsers.add(hashMap);
    } else {
        // we have privileges to see all users -- return the full mapping
        try {
            ArrayList<UserSecurityInfo> allUsers = SecurityServiceUtil.getAllUsers(true, cc);
            for (UserSecurityInfo i : allUsers) {
                hashMap = new HashMap<String, Object>();
                if (i.getType() == UserType.ANONYMOUS) {
                    hashMap.put(USER_ID, "anonymous");
                    hashMap.put(FULL_NAME, User.ANONYMOUS_USER_NICKNAME);
                } else if (i.getEmail() == null) {
                    hashMap.put(USER_ID, "username:" + i.getUsername());
                    if (i.getFullName() == null) {
                        hashMap.put(FULL_NAME, i.getUsername());
                    } else {
                        hashMap.put(FULL_NAME, i.getFullName());
                    }
                } else {
                    // already has the mailto: prefix
                    hashMap.put(USER_ID, i.getEmail());
                    if (i.getFullName() == null) {
                        hashMap.put(FULL_NAME, i.getEmail().substring(EmailParser.K_MAILTO.length()));
                    } else {
                        hashMap.put(FULL_NAME, i.getFullName());
                    }
                }
                processRoles(i.getGrantedAuthorities(), hashMap);
                listOfUsers.add(hashMap);
            }
        } catch (DatastoreFailureException e) {
            logger.error("Retrieving users persistence error: " + e.toString());
            e.printStackTrace();
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    ErrorConsts.PERSISTENCE_LAYER_PROBLEM + "\n" + e.toString());
            return;
        } catch (AccessDeniedException e) {
            logger.error("Retrieving users access denied error: " + e.toString());
            e.printStackTrace();
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
            return;
        }
    }

    resp.addHeader(ApiConstants.OPEN_DATA_KIT_VERSION_HEADER, ApiConstants.OPEN_DATA_KIT_VERSION);
    resp.addHeader("Access-Control-Allow-Origin", "*");
    resp.addHeader("Access-Control-Allow-Credentials", "true");
    resp.addHeader(HttpHeaders.HOST, cc.getServerURL());
    resp.setContentType(HtmlConsts.RESP_TYPE_JSON);
    resp.setCharacterEncoding(HtmlConsts.UTF8_ENCODE);

    PrintWriter out = resp.getWriter();
    out.write(mapper.writeValueAsString(listOfUsers));
    out.flush();

    resp.setStatus(HttpStatus.SC_OK);
}