List of usage examples for javax.servlet ServletException ServletException
public ServletException(Throwable rootCause)
From source file:org.picketlink.test.trust.servlet.GatewayServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { log.info("GatewayServlet:doGet"); String actionParam = req.getParameter(ACTION_PARAM); if (actionParam == null || actionParam.equals(AUTH_INFO)) { authInfoAction(req, resp);// w ww . j a v a 2 s. co m } else if (actionParam.equals(FORWARD_CALL)) { forwardCall(req, resp); } else { PrintWriter out = resp.getWriter(); String unknownAction = "Action: " + ACTION_PARAM + "=" + actionParam + " unknown."; out.println(unknownAction); throw new ServletException(unknownAction); } }
From source file:de.betterform.agent.web.servlet.XFormsRepeater.java
/** * Initializes the servlet./* w ww .ja v a 2s. c o m*/ * * @param config - the ServletConfig object * @throws javax.servlet.ServletException */ public void init(ServletConfig config) throws ServletException { super.init(config); useragent = config.getInitParameter("useragent"); webFactory = new WebFactory(); webFactory.setServletContext(getServletContext()); try { webFactory.initConfiguration(useragent); webFactory.initLogging(getClass()); String realPath = webFactory.getRealPath(".", getServletContext()); webFactory.initTransformerService(realPath); webFactory.initXFormsSessionCache(); } catch (XFormsConfigException e) { throw new ServletException(e); } }
From source file:org.pegadi.webapp.webstart.WebstartController.java
protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { Map<String, Object> model = new HashMap<String, Object>(); List<String> libs = new ArrayList<String>(); configBean.setVersion(resourceBundle.getString("version")); String contextPath = httpServletRequest.getContextPath(); int serverport = httpServletRequest.getServerPort(); String server = httpServletRequest.getServerName(); configBean.setWebBase("http://" + server + ":" + serverport + contextPath); configBean.getProperties().put("server.host", server); File clientFolder = resourceLoader.getResource(configBean.getCodeBase()).getFile(); if (clientFolder.isDirectory()) { File[] files = clientFolder.listFiles(); for (File tempFile : files) { if (!tempFile.getName().contains(".jar")) { continue; }//from w ww.j av a 2 s .c o m if (tempFile.getName().contains(configBean.getMainLibBaseName())) { model.put("main", configBean.getCodeBase() + tempFile.getName()); } else { libs.add(configBean.getCodeBase() + tempFile.getName()); } } } else { log.error("ERROR: clientFolder " + clientFolder.getAbsolutePath() + " is not a directory"); throw new ServletException("WebStartController: Could not read directory containing client jars."); } model.put("jars", libs); model.put("config", configBean); return new ModelAndView("webstart", model); }
From source file:com.sri.save.FloraHttpServlet.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { System.out.println(request);//from ww w . j a v a 2s . com PrintWriter out = response.getWriter(); response.setContentType("application/json"); response.setHeader("Access-Control-Allow-Origin", "*"); // allows CORS // Dispatch the call to the Flora JSON server String method = request.getParameter("method"); if (method.equals("loadFile")) { // perhaps this should be done using POST String filename = request.getParameter("filename"); try { florajson.loadFile(filename); } catch (FloraJsonServerException ex) { throw new ServletException(ex.getMessage()); } } else if (method.equals("getTaxonomyRoots")) { try { ArrayNode result = florajson.getRootClasses(); out.print(result.toString()); } catch (FloraJsonServerException ex) { throw new ServletException(ex.getMessage()); } } else if (method.equals("getSubClasses")) { String id = request.getParameter("id"); try { ObjectNode result = florajson.getSubClasses(id); out.print(result.toString()); } catch (FloraJsonServerException ex) { throw new ServletException(ex.getMessage()); } } else if (method.equals("getClassDetails")) { String id = request.getParameter("id"); try { ObjectNode result = florajson.getClassDetails(id); out.print(result.toString()); } catch (FloraJsonServerException ex) { throw new ServletException(ex.getMessage()); } } else if (method.equals("query")) { String qstring = request.getParameter("queryString"); try { ObjectNode result = florajson.query(qstring); out.print(result.toString()); } catch (FloraJsonServerException ex) { throw new ServletException(ex.getMessage()); } } else throw new ServletException("Unrecognized method: " + method); }
From source file:be.fedict.eid.dss.sp.servlet.UploadServlet.java
@Override @SuppressWarnings("unchecked") protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doPost"); String fileName = null;/*from w ww . j a va 2 s . co m*/ String contentType; byte[] document = null; FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Parse the request try { List<FileItem> items = upload.parseRequest(request); if (!items.isEmpty()) { fileName = items.get(0).getName(); // contentType = items.get(0).getContentType(); document = items.get(0).get(); } } catch (FileUploadException e) { throw new ServletException(e); } String extension = FilenameUtils.getExtension(fileName).toLowerCase(); contentType = supportedFileExtensions.get(extension); if (null == contentType) { /* * Unsupported content-type is converted to a ZIP container. */ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream); ZipEntry zipEntry = new ZipEntry(fileName); zipOutputStream.putNextEntry(zipEntry); IOUtils.write(document, zipOutputStream); zipOutputStream.close(); fileName = FilenameUtils.getBaseName(fileName) + ".zip"; document = outputStream.toByteArray(); contentType = "application/zip"; } LOG.debug("File name: " + fileName); LOG.debug("Content Type: " + contentType); String signatureRequest = new String(Base64.encode(document)); request.getSession().setAttribute(DOCUMENT_SESSION_ATTRIBUTE, document); request.getSession().setAttribute("SignatureRequest", signatureRequest); request.getSession().setAttribute("ContentType", contentType); response.sendRedirect(request.getContextPath() + this.postPage); }
From source file:io.fabric8.apiman.BearerTokenFilter.java
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) *//*from ww w . j av a 2s.c om*/ @Override public void init(FilterConfig config) throws ServletException { String kubernetesHostAndPort = Systems.getServiceHostAndPort("KUBERNETES", "172.28.128.4", "8443"); kubernetesTrustCert = Boolean .parseBoolean(Systems.getEnvVarOrSystemProperty("KUBERNETES_TRUST_CERT", "true")); try { kubernetesOsapiUrl = new URL("https://" + kubernetesHostAndPort + KUBERNETES_OSAPI_URL + "/users/"); } catch (MalformedURLException e) { throw new ServletException(e); } }
From source file:org.remus.marketplace.servlets.ContentListing.java
@Override public void handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { int contentId = Integer.parseInt(arg0.getParameter("nodeId")); arg1.setContentType("text/xml"); try {/*from www . jav a 2 s.co m*/ JAXBContext newInstance = JAXBContext.newInstance(Marketplace.class, org.remus.marketplace.xml.Node.class, Platforms.class, Platform.class, IUs.class, IU.class); Marketplace marketplace = new Marketplace(); Node findById = nodeDao.findById(contentId); if (findById != null) { org.remus.marketplace.xml.Node node = XMLBuilder.buildNode(serverPrefix, findById); marketplace.setNode(node); Marshaller createMarshaller = newInstance.createMarshaller(); XMLSerializer xmlSerializer = XMLBuilder.getXMLSerializer(arg1.getOutputStream()); createMarshaller.marshal(marketplace, xmlSerializer.asContentHandler()); } else { throw new ServletException("Node not found"); } } catch (JAXBException e) { throw new ServletException(e); } }
From source file:org.soulwing.cas.filter.FilterToBeanProxy.java
private String getTargetBeanName(FilterConfig filterConfig) throws ServletException { String beanName = filterConfig.getInitParameter(TARGET_BEAN); if (beanName == null) { throw new ServletException(TARGET_BEAN + INIT_PARAMETER_REQUIRED); }/* w w w . j ava2 s . c o m*/ return beanName; }
From source file:com.adobe.acs.commons.analysis.jcrchecksum.impl.servlets.ChecksumGeneratorServlet.java
public final void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException { try {/*from w w w . ja v a 2 s . c om*/ this.handleCORS(request, response); this.handleRequest(request, response); } catch (IOException e) { throw new ServletException(e); } catch (RepositoryException e) { throw new ServletException(e); } }
From source file:com.bluexml.xforms.chiba.XFormsFilter.java
@Override public void doFilter(ServletRequest srvRequest, ServletResponse srvResponse, FilterChain filterChain) throws IOException, ServletException { //ensure correct Request encoding if (srvRequest.getCharacterEncoding() == null) { srvRequest.setCharacterEncoding(defaultRequestEncoding); }//from w w w . j av a 2 s .co m HttpServletRequest request = (HttpServletRequest) srvRequest; HttpServletResponse response = (HttpServletResponse) srvResponse; HttpSession session = request.getSession(true); if ("GET".equalsIgnoreCase(request.getMethod()) && request.getParameter("submissionResponse") != null) { doSubmissionResponse(request, response); } else { /* before servlet request */ if (isXFormUpdateRequest(request)) { LOG.info("Start Update XForm"); try { XFormsSession xFormsSession = WebUtil.getXFormsSession(request, session); xFormsSession.setRequest(request); xFormsSession.setResponse(response); xFormsSession.handleRequest(); } catch (XFormsException e) { throw new ServletException(e); } LOG.info("End Update XForm"); } else { /* do servlet request */ LOG.info("Passing to Chain"); BufferedHttpServletResponseWrapper bufResponse = new BufferedHttpServletResponseWrapper( (HttpServletResponse) srvResponse); filterChain.doFilter(srvRequest, bufResponse); LOG.info("Returned from Chain"); // response is already committed to the client, so nothing is to // be done if (bufResponse.isCommitted()) return; //set mode of operation (scripted/nonscripted) by config if (this.mode == null) this.mode = "true"; if (this.mode.equalsIgnoreCase("true")) { request.setAttribute(WebFactory.SCRIPTED, "true"); } else if (this.mode.equalsIgnoreCase("false")) { request.setAttribute(WebFactory.SCRIPTED, "false"); } /* dealing with response from chain */ if (handleResponseBody(request, bufResponse)) { byte[] data = prepareData(bufResponse); if (data.length > 0) { request.setAttribute(WebFactory.XFORMS_INPUTSTREAM, new ByteArrayInputStream(data)); } } if (handleRequestAttributes(request)) { bufResponse.getOutputStream().close(); LOG.info("Start Filter XForm"); XFormsSession xFormsSession = null; try { XFormsSessionManager sessionManager = DefaultXFormsSessionManagerImpl .getXFormsSessionManager(); xFormsSession = sessionManager.createXFormsSession(request, response, session); xFormsSession.setBaseURI(request.getRequestURL().toString()); xFormsSession.setXForms(); xFormsSession.init(); // FIXME patch for upload XFormsSessionBase xFormsSessionBase = (XFormsSessionBase) xFormsSession; reconfigure(xFormsSessionBase); xFormsSession.handleRequest(); } catch (Exception e) { LOG.error(e.getMessage(), e); if (xFormsSession != null) { xFormsSession.close(e); } throw new ServletException(e.getMessage()); } LOG.info("End Render XForm"); } else { srvResponse.getOutputStream().write(bufResponse.getData()); srvResponse.getOutputStream().close(); } } } }