List of usage examples for javax.servlet.http HttpServletResponse SC_METHOD_NOT_ALLOWED
int SC_METHOD_NOT_ALLOWED
To view the source code for javax.servlet.http HttpServletResponse SC_METHOD_NOT_ALLOWED.
Click Source Link
Request-Line
is not allowed for the resource identified by the Request-URI
. From source file:com.vigglet.servlet.PostJsonServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); }
From source file:com.mirth.connect.server.MethodFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { String method = ((HttpServletRequest) req).getMethod(); // Don't allow TRACE/TRACK requests if (StringUtils.equalsIgnoreCase(method, "TRACE") || StringUtils.equalsIgnoreCase(method, "TRACK")) { ((HttpServletResponse) res).sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } else {/* w ww . j a va2s . co m*/ chain.doFilter(req, res); } }
From source file:com.enonic.cms.web.CmsDispatcherServlet.java
protected void doService(HttpServletRequest req, HttpServletResponse res) throws Exception { final HttpMethod requestMethod = HttpMethod.valueOf(req.getMethod()); if (!ALLOWED_HTTP_METHODS.contains(requestMethod)) { res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return;/* w w w. j a va2s. com*/ } ServletRequestAccessor.setRequest(req); OriginalUrlResolver.resolveOriginalUrl(req); super.doService(req, res); }
From source file:org.openmrs.module.document.web.controller.UploadController.java
@RequestMapping(method = RequestMethod.GET) @ResponseBody/* w w w . j a va 2 s. c o m*/ public void onGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "This method is not allowed."); }
From source file:cf.spring.servicebroker.CatalogHandler.java
@Override public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (!"get".equalsIgnoreCase(request.getMethod())) { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return;//w w w . ja v a 2 s . c om } if (!authenticator.authenticate(request, response)) { return; } ApiVersionValidator.validateApiVersion(request); response.setContentType(Constants.JSON_CONTENT_TYPE); mapper.writeValue(response.getOutputStream(), catalog.get()); }
From source file:eu.morfeoproject.fast.catalogue.services.GenericServlet.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) *///www .j a v a 2 s .co m @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); }
From source file:com.thinkberg.moxo.dav.MkColHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { if (request.getReader().readLine() != null) { response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); return;/*w w w. j a v a2 s. c om*/ } FileObject object = getResourceManager().getFileObject(request.getPathInfo()); try { LockManager.getInstance().checkCondition(object, getIf(request)); } catch (LockException e) { if (e.getLocks() != null) { response.sendError(SC_LOCKED); } else { response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); } return; } if (object.exists()) { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return; } if (!object.getParent().exists() || !FileType.FOLDER.equals(object.getParent().getType())) { response.sendError(HttpServletResponse.SC_CONFLICT); return; } try { object.createFolder(); response.setStatus(HttpServletResponse.SC_CREATED); } catch (FileSystemException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } }
From source file:com.enonic.cms.web.portal.PortalServlet.java
@Override protected void service(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException { final String requestMethod = req.getMethod(); if (!ALLOWED_HTTP_METHODS.contains(requestMethod)) { res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return;//from w w w .j a v a 2s . c o m } if (requestMethod.equals("OPTIONS")) { doOptions(req, res); return; } ServletRequestAccessor.setRequest(req); OriginalUrlResolver.resolveOriginalUrl(req); this.dispatcher.handle(req, res); }
From source file:gov.redhawk.rap.internal.PluginProviderServlet.java
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final Path path = new Path(req.getRequestURI()); String pluginId = path.lastSegment(); if (pluginId.endsWith(".jar")) { pluginId = pluginId.substring(0, pluginId.length() - 4); }/*from w w w . ja va2 s. co m*/ final Bundle b = Platform.getBundle(pluginId); if (b == null) { final String protocol = req.getProtocol(); final String msg = "Plugin does not exist: " + pluginId; if (protocol.endsWith("1.1")) { resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg); } else { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); } return; } final File file = FileLocator.getBundleFile(b); resp.setContentType("application/octet-stream"); if (file.isFile()) { final String contentDisposition = "attachment; filename=\"" + file.getName() + "\""; resp.setHeader("Content-Disposition", contentDisposition); resp.setContentLength((int) file.length()); final FileInputStream istream = new FileInputStream(file); try { IOUtils.copy(istream, resp.getOutputStream()); } finally { istream.close(); } resp.flushBuffer(); } else { final String contentDisposition = "attachment; filename=\"" + file.getName() + ".jar\""; resp.setHeader("Content-Disposition", contentDisposition); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final Manifest man = new Manifest(new FileInputStream(new File(file, "META-INF/MANIFEST.MF"))); final JarOutputStream out = new JarOutputStream(outputStream, man); final File binDir = new File(file, "bin"); if (binDir.exists()) { addFiles(out, Path.ROOT, binDir.listFiles()); for (final File f : file.listFiles()) { if (!f.getName().equals("bin")) { addFiles(out, Path.ROOT, f); } } } else { addFiles(out, Path.ROOT, file.listFiles()); } out.close(); outputStream.close(); final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); resp.setContentLength(outputStream.size()); try { IOUtils.copy(inputStream, resp.getOutputStream()); } finally { inputStream.close(); } resp.flushBuffer(); } }
From source file:org.infoscoop.admin.web.AuthenticationServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //doPost(request, response); response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); }