Example usage for javax.servlet.http HttpServletResponse SC_NO_CONTENT

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

Introduction

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

Prototype

int SC_NO_CONTENT

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

Click Source Link

Document

Status code (204) indicating that the request succeeded but that there was no new information to return.

Usage

From source file:com.imaginary.home.cloud.api.call.RelayCall.java

private void update(ControllerRelay relay, JSONObject state, HttpServletResponse resp)
        throws RestException, IOException, JSONException {
    try {/*from ww w.j  a  va2 s. com*/
        if (state.has("relay")) {
            JSONObject r = state.getJSONObject("relay");

            if (r.has("devices")) {
                HashMap<String, Device> found = new HashMap<String, Device>();
                JSONArray devices = r.getJSONArray("devices");

                for (int i = 0; i < devices.length(); i++) {
                    JSONObject device = devices.getJSONObject(i);

                    if (!device.has("deviceId") || device.isNull("deviceId") || !device.has("deviceType")
                            || device.isNull("deviceType") || !device.has("systemId")
                            || device.isNull("systemId")) {
                        continue;
                    }
                    String id = device.getString("deviceId");
                    String t = device.getString("deviceType");
                    String systemId = device.getString("systemId");
                    Device d = Device.getDevice(t, relay, systemId, id);

                    if (d == null) {
                        d = Device.create(relay, t, device);
                    } else {
                        d.update(device);
                    }
                    found.put(d.getDeviceId(), d);
                }
                for (Device d : Device.findDevicesForRelay(relay)) {
                    if (!found.containsKey(d.getDeviceId())) {
                        d.remove();
                    }
                }
            }
        }
        resp.addHeader("x-imaginary-has-commands", String.valueOf(PendingCommand.hasCommands(relay)));
        resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } catch (PersistenceException e) {
        throw new RestException(e);
    }
}

From source file:com.xpn.xwiki.web.SaveAction.java

@Override
public boolean action(XWikiContext context) throws XWikiException {
    // CSRF prevention
    if (!csrfTokenCheck(context)) {
        return false;
    }//from   w ww.  j a  v a  2  s  .  c om

    if (save(context)) {
        return true;
    }
    // forward to view
    if (Utils.isAjaxRequest(context)) {
        context.getResponse().setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {
        sendRedirect(context.getResponse(), Utils.getRedirect("view", context));
    }
    return false;
}

From source file:org.opencastproject.episode.endpoint.EpisodeRestService.java

@POST
@Path("applyworkflow")
@RestQuery(name = "applyworkflow", description = "Apply a workflow to a list of media packages. Choose to either provide "
        + "a workflow definition or a workflow definition identifier.", restParameters = {
                @RestParameter(description = "The workflow definition in XML format.", isRequired = false, name = "definition", type = RestParameter.Type.TEXT),
                @RestParameter(description = "The workflow definition ID.", isRequired = false, name = "definitionId", type = RestParameter.Type.TEXT),
                @RestParameter(description = "A list of media package ids.", isRequired = true, name = "id", type = RestParameter.Type.STRING) }, reponses = {
                        @RestResponse(description = "The workflows have been started.", responseCode = HttpServletResponse.SC_NO_CONTENT) }, returnDescription = "No content is returned.")
public Response applyWorkflow(@FormParam("definition") String workflowDefinitionXml,
        @FormParam("definitionId") String workflowDefinitionId, @FormParam("id") List<String> mediaPackageId)
        throws UnauthorizedException {
    if (mediaPackageId == null || mediaPackageId.size() == 0)
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    boolean workflowDefinitionXmlPresent = StringUtils.isNotBlank(workflowDefinitionXml);
    boolean workflowDefinitionIdPresent = StringUtils.isNotBlank(workflowDefinitionId);
    if (!(workflowDefinitionXmlPresent ^ workflowDefinitionIdPresent))
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    if (workflowDefinitionXmlPresent) {
        WorkflowDefinition workflowDefinition;
        try {/* w w w .  j a  va  2 s.c  o m*/
            workflowDefinition = WorkflowParser.parseWorkflowDefinition(workflowDefinitionXml);
        } catch (WorkflowParsingException e) {
            throw new WebApplicationException(e);
        }
        episodeService.applyWorkflow(workflowDefinition, mediaPackageId);
        return Response.noContent().build();
    } else {
        episodeService.applyWorkflow(workflowDefinitionId, mediaPackageId);
        return Response.noContent().build();
    }
}

From source file:org.eclipse.orion.server.servlets.PreferencesServlet.java

@SuppressWarnings("unchecked")
@Override//from w  w  w .j  ava  2 s  . c o  m
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    traceRequest(req);
    MetadataInfo info = getNode(req, resp);
    if (info == null)
        return;
    String key = req.getParameter("key"); //$NON-NLS-1$
    String prefix = getPrefix(req);
    try {
        boolean changed = false;
        if (key != null) {
            prefix = prefix + '/' + key;
            String newValue = req.getParameter("value"); //$NON-NLS-1$
            String oldValue = info.setProperty(prefix.toString(), newValue);
            changed = !newValue.equals(oldValue);
        } else {
            JSONObject newNode = new JSONObject(new JSONTokener(req.getReader()));
            //can't overwrite base user settings via preference servlet
            if (prefix.startsWith("user/")) {
                resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
                return;
            }
            //operations should not be removed by PUT
            if (!prefix.equals("operations")) {

                //clear existing values matching prefix
                changed |= removeMatchingProperties(info, prefix.toString());
            }
            for (Iterator<String> it = newNode.keys(); it.hasNext();) {
                key = it.next();
                String newValue = newNode.getString(key);
                String qualifiedKey = prefix + '/' + key;
                String oldValue = info.setProperty(qualifiedKey, newValue);
                changed |= !newValue.equals(oldValue);
            }
        }
        if (changed)
            save(info);
        resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } catch (Exception e) {
        handleException(resp, NLS.bind("Failed to store preferences for {0}", req.getRequestURL()), e);
        return;
    }
}

From source file:com.adito.core.actions.AuthenticatedDispatchAction.java

/**
 * This abstract class will populate all the common variables required by an
 * action within the webstudio framework, such as current user, permission
 * database, user database etc/* ww w. j a  v  a  2s . c  o m*/
 * 
 * @param mapping
 * @param form
 * @param request
 * @param response
 * 
 * @exception Exception if business logic throws an exception
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    // Setup mode
    boolean setupMode = ContextHolder.getContext().isSetupMode();
    if (setupMode) {
        if ((getNavigationContext(mapping, form, request, response) & SessionInfo.SETUP_CONSOLE_CONTEXT) == 0) {
            return mapping.findForward("setup");
        } else {
            /*
             * Make the mapping and form available, this helps with reusing
             * some JSP pages
             */
            request.setAttribute(Constants.REQ_ATTR_ACTION_MAPPING, mapping);
            request.setAttribute(Constants.REQ_ATTR_FORM, form);

            //
            CoreUtil.checkNavigationContext(this, mapping, form, request, response);
            return super.execute(mapping, form, request, response);
        }
    }
    try {
        try {
            if (!SystemDatabaseFactory.getInstance().verifyIPAddress(request.getRemoteAddr())) {
                String link = null;
                log.error(request.getRemoteHost() + " is not authorized");
                if (log.isInfoEnabled())
                    log.info("Logging off, IP address verification failed.");

                if (LogonControllerFactory.getInstance().hasClientLoggedOn(request,
                        response) == LogonController.LOGGED_ON) {
                    LogonControllerFactory.getInstance().logoffSession(request, response);
                }

                if (link != null) {
                    ActionForward fwd = new ActionForward(link, true);
                    return fwd;
                } else {
                    // Do not direct to logon page for Ajax requests
                    if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
                        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
                        return null;
                    }
                    return (mapping.findForward("logon"));
                }
            } else {
                /*
                 * Make the mapping and form available, this helps with
                 * reusing some JSP pages
                 */
                request.setAttribute(Constants.REQ_ATTR_ACTION_MAPPING, mapping);
                request.setAttribute(Constants.REQ_ATTR_FORM, form);

                int logonStatus = LogonControllerFactory.getInstance().hasClientLoggedOn(request, response);
                if (logonStatus == LogonController.INVALID_TICKET) {
                    ActionMessages msgs = new ActionMessages();
                    msgs.add(Globals.ERROR_KEY, new ActionMessage("login.invalidTicket"));
                    saveErrors(request, msgs);
                } else if (logonStatus == LogonController.LOGGED_ON) {
                    SessionInfo session = LogonControllerFactory.getInstance().getSessionInfo(request);
                    // Set the logon ticket / domain logon ticket again
                    LogonControllerFactory.getInstance().addCookies(new ServletRequestAdapter(request),
                            new ServletResponseAdapter(response),
                            (String) request.getSession().getAttribute(Constants.LOGON_TICKET),
                            getSessionInfo(request));

                    ActionForward fwd = checkIntercept(mapping, request, response);
                    if (fwd != null) {
                        return fwd;
                    }

                    /*
                     * Make sure the current navigation context is correct.
                     * If not, then check the user can switch to the correct
                     * and switch it.
                     */
                    CoreUtil.checkNavigationContext(this, mapping, form, request, response);

                    PropertyProfile profile = null;
                    if (request.getSession().getAttribute(Constants.SESSION_LOCKED) == null) {
                        profile = (PropertyProfile) request.getSession()
                                .getAttribute(Constants.SELECTED_PROFILE);
                        if (profile == null) {
                            request.getSession().setAttribute(Constants.ORIGINAL_REQUEST,
                                    Util.getOriginalRequest(request));
                            return mapping.findForward("selectPropertyProfile");
                        }
                        doCheckPermissions(mapping, session, request);
                        return super.execute(mapping, form, request, response);
                    }
                }
            }
        } catch (NoPermissionException e) {
            if (log.isDebugEnabled())
                log.debug("User " + e.getPrincipalName()
                        + " attempted to access page they do have have permission for. Resource type = "
                        + e.getResourceType()
                        + ". Now attempting to find the first valid item in the current menu tree to display.",
                        e);
            response.sendError(HttpServletResponse.SC_FORBIDDEN);
            return null;
        } catch (SecurityException ex) {
            // Not logged in or expired
        } catch (ServletException ex) {
            throw ex;
        }

        // Do not direct to logon page for Ajax requests
        if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
            response.setStatus(HttpServletResponse.SC_NO_CONTENT);
            return null;
        }

        return gotoLogon(mapping, form, request, response);
    } catch (Throwable t) {
        log.error("Failed to process authenticated request.", t);
        throw t instanceof Exception ? (Exception) t : new Exception(t);
    }
}

From source file:org.eclipse.orion.internal.server.servlets.file.FileHandlerV1.java

@Override
public boolean handleRequest(HttpServletRequest request, HttpServletResponse response, IFileStore file)
        throws ServletException {
    try {//ww  w . j  av  a  2s. c  om
        String receivedETag = request.getHeader(ProtocolConstants.HEADER_IF_MATCH);
        if (receivedETag != null && !receivedETag.equals(generateFileETag(file))) {
            response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
            return true;
        }
        String parts = IOUtilities.getQueryParameter(request, "parts");
        if (parts == null || "body".equals(parts)) { //$NON-NLS-1$
            switch (getMethod(request)) {
            case DELETE:
                file.delete(EFS.NONE, null);
                break;
            case PUT:
                handlePutContents(request, request.getReader(), response, file);
                break;
            case POST:
                if ("PATCH".equals(request.getHeader(ProtocolConstants.HEADER_METHOD_OVERRIDE))) {
                    handlePatchContents(request, request.getReader(), response, file);
                }
                break;
            default:
                return handleFileContents(request, response, file);
            }
            return true;
        }
        if ("meta".equals(parts)) { //$NON-NLS-1$
            switch (getMethod(request)) {
            case GET:
                response.setCharacterEncoding("UTF-8");
                handleGetMetadata(request, response, response.getWriter(), file);
                return true;
            case PUT:
                handlePutMetadata(request.getReader(), null, file);
                response.setStatus(HttpServletResponse.SC_NO_CONTENT);
                return true;
            }
            return false;
        }
        if ("meta,body".equals(parts) || "body,meta".equals(parts)) { //$NON-NLS-1$ //$NON-NLS-2$
            switch (getMethod(request)) {
            case GET:
                handleMultiPartGet(request, response, file);
                return true;
            case PUT:
                handleMultiPartPut(request, response, file);
                return true;
            }
            return false;
        }
    } catch (JSONException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR,
                HttpServletResponse.SC_BAD_REQUEST, "Syntax error in request", e));
    } catch (Exception e) {
        if (!handleAuthFailure(request, response, e))
            throw new ServletException(NLS.bind("Error retrieving file: {0}", file), e);
    }
    return false;
}

From source file:org.dasein.cloud.rackspace.AbstractMethod.java

protected void delete(@Nonnull String authToken, @Nonnull String endpoint, @Nonnull String resource)
        throws CloudException, InternalException {
    Logger std = RackspaceCloud.getLogger(RackspaceCloud.class, "std");
    Logger wire = RackspaceCloud.getLogger(RackspaceCloud.class, "wire");

    if (std.isTraceEnabled()) {
        std.trace("enter - " + AbstractMethod.class.getName() + ".delete(" + authToken + "," + endpoint + ","
                + resource + ")");
    }/*  w w  w.j a  v  a 2s  .  c o m*/
    if (wire.isDebugEnabled()) {
        wire.debug("--------------------------------------------------------> " + endpoint + resource);
        wire.debug("");
    }
    try {
        HttpClient client = getClient();
        HttpDelete delete = new HttpDelete(endpoint + resource);

        delete.addHeader("Content-Type", "application/json");
        delete.addHeader("X-Auth-Token", authToken);

        if (wire.isDebugEnabled()) {
            wire.debug(delete.getRequestLine().toString());
            for (Header header : delete.getAllHeaders()) {
                wire.debug(header.getName() + ": " + header.getValue());
            }
            wire.debug("");
        }
        HttpResponse response;

        try {
            response = client.execute(delete);
            if (wire.isDebugEnabled()) {
                wire.debug(response.getStatusLine().toString());
                for (Header header : response.getAllHeaders()) {
                    wire.debug(header.getName() + ": " + header.getValue());
                }
                wire.debug("");
            }
        } catch (IOException e) {
            std.error("I/O error from server communications: " + e.getMessage());
            e.printStackTrace();
            throw new InternalException(e);
        }
        int code = response.getStatusLine().getStatusCode();

        std.debug("HTTP STATUS: " + code);

        if (code != HttpServletResponse.SC_NO_CONTENT && code != HttpServletResponse.SC_ACCEPTED) {
            std.error("delete(): Expected NO CONTENT for DELETE request, got " + code);
            HttpEntity entity = response.getEntity();
            String json = null;

            if (entity != null) {
                try {
                    json = EntityUtils.toString(entity);

                    if (wire.isDebugEnabled()) {
                        wire.debug(json);
                        wire.debug("");
                    }
                } catch (IOException e) {
                    throw new CloudException(e);
                }
            }
            RackspaceException.ExceptionItems items = (json == null ? null
                    : RackspaceException.parseException(code, json));

            if (items == null) {
                items = new RackspaceException.ExceptionItems();
                items.code = 404;
                items.type = CloudErrorType.COMMUNICATION;
                items.message = "itemNotFound";
                items.details = "No such object: " + resource;
            }
            std.error("delete(): [" + code + " : " + items.message + "] " + items.details);
            throw new RackspaceException(items);
        } else {
            wire.debug("");
        }
    } finally {
        if (std.isTraceEnabled()) {
            std.trace("exit - " + AbstractMethod.class.getName() + ".delete()");
        }
        if (wire.isDebugEnabled()) {
            wire.debug("");
            wire.debug("--------------------------------------------------------> " + endpoint + resource);
        }
    }
}

From source file:ca.simplegames.micro.Micro.java

public RackResponse call(Context<String> input) {

    MicroContext context = new MicroContext<String>();

    //try {/*ww  w .j  av  a  2 s  . c  o  m*/
    input.with(Globals.SITE, site);
    input.with(Rack.RACK_LOGGER, log);

    String pathInfo = input.get(Rack.PATH_INFO);
    context.with(Globals.RACK_INPUT, input).with(Globals.SITE, site).with(Rack.RACK_LOGGER, log)
            .with(Globals.LOG, log).with(Globals.REQUEST, context.getRequest())
            .with(Globals.MICRO_ENV, site.getMicroEnv())
            // .with(Globals.CONTEXT, context) <-- don't, please!
            .with(Globals.PARAMS, input.get(Rack.PARAMS)).with(Globals.PARAMS, ParamsFactory.capture(context)) //<- wrap them nicely
            .with(Globals.SITE, site).with(Globals.PATH_INFO, pathInfo).with(TOOLS, tools);

    input.with(Globals.CONTEXT, context); // mostly for helping the testing effort

    context.with(Globals.MICRO_TEMPLATE_ENGINES, new TemplateEngineWrapper(context));
    for (Repository repository : site.getRepositoryManager().getRepositories()) {
        context.with(repository.getName(), repository.getRepositoryWrapper(context));
    }

    RackResponse response = new RackResponse(RackResponseUtils.ReturnCode.OK).withContentType(null)
            .withContentLength(0); // a la Sinatra, they're doing it right

    context.setRackResponse(response);

    try {
        // inject the Helpers into the current context
        List<HelperWrapper> helpers = site.getHelperManager().getHelpers();
        if (!helpers.isEmpty()) {
            for (HelperWrapper helper : helpers) {
                if (helper != null) {
                    context.with(helper.getName(), helper.getInstance(context));
                }
            }
        }

        if (site.getFilterManager() != null) {
            callFilters(site.getFilterManager().getBeforeFilters(), context);
        }

        if (!context.isHalt()) {
            String path = input.get(JRack.PATH_INFO);
            if (StringUtils.isBlank(path)) {
                path = input.get(Rack.SCRIPT_NAME);
            }

            if (site.getRouteManager() != null) {
                site.getRouteManager().call(path, context);
            }

            // Routes or filters providing their own Views will most probably ask a flow interruption, hence the
            // next check for isHalt()
            if (!context.isHalt()) {
                path = (String) context.get(Globals.PATH);
                if (path == null) { // user not deciding the PATH
                    path = maybeAppendHtmlToPath(context);
                    context.with(Globals.PATH,
                            path.contains(DOUBLE_SLASH) ? path.replace(DOUBLE_SLASH, SLASH) : path);
                }

                final String pathBasedContentType = PathUtilities
                        .extractType((String) context.get(Globals.PATH));

                String templateName = StringUtils.defaultString(context.getTemplateName(),
                        RepositoryManager.DEFAULT_TEMPLATE_NAME);

                Repository defaultRepository = site.getRepositoryManager().getDefaultRepository();
                // verify if there is a default repository decided by 3rd party components; controllers, extensions, etc.
                if (context.getDefaultRepositoryName() != null) {
                    defaultRepository = site.getRepositoryManager()
                            .getRepository(context.getDefaultRepositoryName());
                }

                // calculate the Template name
                View view = (View) context.get(Globals.VIEW);
                if (view != null && StringUtils.isNotBlank(view.getTemplate())) {
                    templateName = view.getTemplate();
                } else {
                    view = defaultRepository.getView(path);
                    if (view != null && view.getTemplate() != null) {
                        templateName = view.getTemplate();
                    }
                }

                if (!site.isLegacy()) {
                    // Execute the View Filters and Controllers (if any), render it and save it as the context 'yield' var
                    context.put(Globals.YIELD, defaultRepository.getRepositoryWrapper(context).get(path));
                }

                // Render the Default Template. The template will pull out the View via the Globals.YIELD, and the result being
                // sent out as the Template body merged with the View's own content. The Controllers are executed *before*
                // rendering the View, any context artifacts being available to the Template as well.

                Repository templatesRepository = site.getRepositoryManager().getTemplatesRepository();
                if (context.getTemplatesRepositoryName() != null) {
                    templatesRepository = site.getRepositoryManager()
                            .getRepository(context.getTemplatesRepositoryName());
                }

                if (templatesRepository != null) {
                    String out = templatesRepository.getRepositoryWrapper(context)
                            .get(templateName + pathBasedContentType);

                    response.withContentLength(out.getBytes(Charset.forName(Globals.UTF8)).length)
                            .withBody(out);
                } else {
                    throw new FileNotFoundException(
                            String.format("templates repository: %s", context.getTemplatesRepositoryName()));
                }
            }

            if (!context.isHalt()) {
                if (site.getFilterManager() != null) {
                    callFilters(site.getFilterManager().getAfterFilters(), context);
                }
            }
        }

        return context.getRackResponse().withContentType(getContentType(context));

    } catch (ControllerNotFoundException e) {
        context.with(Globals.ERROR, e);
        return badJuju(context, HttpServletResponse.SC_NO_CONTENT, e);
    } catch (ControllerException e) {
        context.with(Globals.ERROR, e);
        return badJuju(context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
    } catch (FileNotFoundException e) {
        context.with(Globals.ERROR, e);
        return badJuju(context, HttpServletResponse.SC_NOT_FOUND, e);
    } catch (ViewException e) {
        context.with(Globals.ERROR, e);
        return badJuju(context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
    } catch (RedirectException re) {
        return context.getRackResponse();
    } catch (Exception e) { // must think more about this one :(
        context.with(Globals.ERROR, e);
        e.printStackTrace();
        return badJuju(context, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
    }
    // Experimental!!!!!!
    //        } finally {
    //            // this is an experimental trick that will save some processing time required by BSF to load
    //            // various engines.
    //            @SuppressWarnings("unchecked")
    //            CloseableThreadLocal<BSFManager> closeableBsfManager = (CloseableThreadLocal<BSFManager>)
    //                    context.get(Globals.CLOSEABLE_BSF_MANAGER);
    //            if(closeableBsfManager!=null){
    //                closeableBsfManager.close();
    //            }
    //    }
}

From source file:org.ednovo.gooru.controllers.v2.api.ApplicationRestV2Controller.java

@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_APPLICATION_DELETE })
@RequestMapping(method = { RequestMethod.DELETE }, value = "/{id}")
public void deleteApplication(@PathVariable(value = ID) String apikey, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    this.getApplicationService().deleteApplication(apikey);
    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}

From source file:com.rsginer.spring.controllers.RestaurantesController.java

@RequestMapping(value = {
        "/delete-restaurante/{id}" }, method = RequestMethod.DELETE, produces = "application/json")
public void removeRestaurante(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse,
        @PathVariable("id") int idRestaurante) {
    try {//from   w  w w .j a v  a 2 s  .com
        restaurantesDAO.delete(idRestaurante);
        httpServletResponse.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } catch (BussinessException ex) {
        List<BussinessMessage> bussinessMessages = ex.getBussinessMessages();
        String jsonSalida = jsonTransformer.toJson(bussinessMessages);
        httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        httpServletResponse.setContentType("application/json; charset=UTF-8");
        try {
            httpServletResponse.getWriter().println(jsonSalida);
        } catch (IOException ex1) {
            Logger.getLogger(RestaurantesController.class.getName()).log(Level.SEVERE, null, ex1);
        }
    } catch (Exception ex) {
        httpServletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        httpServletResponse.setContentType("text/plain; charset=UTF-8");
        try {
            ex.printStackTrace(httpServletResponse.getWriter());
        } catch (IOException ex1) {
            Logger.getLogger(RestaurantesController.class.getName()).log(Level.SEVERE, null, ex1);
        }
    }
}