List of usage examples for javax.servlet ServletException ServletException
public ServletException(Throwable rootCause)
From source file:org.wallride.web.support.ExtendedUrlRewriteFilter.java
@Override protected void loadUrlRewriter(FilterConfig filterConfig) throws ServletException { try {/*from w ww . java 2 s. co m*/ Conf conf = new Conf(); conf.addRule(new RuleImpl(new BlogLanguageRewriteRule(blogService))); conf.initialise(); checkConf(conf); } catch (Throwable e) { logger.error("Can not read ", e); throw new ServletException(e); } }
From source file:com.earldouglas.filtre.Filtre.java
public void init(FilterConfig filterConfig) throws ServletException { try {//from ww w . j a v a 2 s.c o m if (filterConfig.getInitParameter("whiteList") == null && filterConfig.getInitParameter("blackList") == null && filterConfig.getInitParameter("configLocation") == null) { useConfigLocation("classpath:filtre.properties"); } else { addressManager.extendWhiteList(filterConfig.getInitParameter("whiteList")); addressManager.extendBlackList(filterConfig.getInitParameter("blackList")); useConfigLocation(filterConfig.getInitParameter("configLocation")); } } catch (AddressFormatException addressFormatException) { throw new ServletException(addressFormatException); } }
From source file:common.web.servlets.StaticFilesServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); if (config != null) { String prop_file = config.getInitParameter(PROPERTIES_PATH_NAME); if (prop_file == null || prop_file.equals("")) throw new ServletException("properties_file not specified"); //loadFromPropertiesFile( config.getServletContext().getRealPath(prop_file) ); loadFromPropertiesFile(prop_file); config.getServletContext().setAttribute("NewIO", newStat); config.getServletContext().setAttribute("OldIO", oldStat); }// www. ja v a 2 s . co m if (realPath == null) throw new ServletException("path to directory not found"); }
From source file:com.googlecode.jsfFlex.phaseListener.RawServiceRequestDataRetrieverFlusher.java
@Override void retrieveFlushData(FacesContext context, String componentId, String methodToInvoke) throws ServletException, IOException { Collection<? extends Object> objectCollection = null; try {//w w w . ja va 2 s. c om objectCollection = (Collection<? extends Object>) invokeResourceMethod(context, componentId, methodToInvoke, null, null); } catch (Exception methodInvocationException) { throw new ServletException(methodInvocationException); } HttpServletResponse response = HttpServletResponse.class.cast(context.getExternalContext().getResponse()); response.setContentType(PLAIN_CONTENT_TYPE); if (objectCollection != null) { StringBuilder responseContent = new StringBuilder(); for (Object currObj : objectCollection) { responseContent.append(currObj.toString()); } _log.info("Flushing content : " + responseContent.toString()); Writer writer = response.getWriter(); writer.write(responseContent.toString()); writer.flush(); } }
From source file:edu.jhu.pha.vospace.SettingsServlet.java
@Override public void init() throws ServletException { try {/* w w w . java 2 s . co m*/ DefaultConfigurationBuilder factory = new DefaultConfigurationBuilder( getServletConfig().getInitParameter("settingsFileName")); Configuration config = factory.getConfiguration(); getServletContext().setAttribute("configuration", config); SettingsServlet.config = config; } catch (ConfigurationException e) { logger.error("Error loading configuration", e); throw new ServletException(e); } }
From source file:com.collective.celos.servlet.RegisterKeysServlet.java
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException { try {//from www . ja va 2 s . c om BucketID bucket = new BucketID(req.getParameter(CelosClient.BUCKET_PARAM)); String prefix = req.getParameter(CelosClient.PREFIX_PARAM); try (StateDatabaseConnection connection = getStateDatabase().openConnection()) { Set<RegisterKey> keys = connection.getRegisterKeys(bucket, prefix); ObjectNode object = Util.MAPPER.createObjectNode(); ArrayNode list = Util.MAPPER.createArrayNode(); object.put(CelosClient.KEYS_NODE, list); keys.stream().sorted().forEach(x -> list.add(x.toString())); writer.writeValue(res.getOutputStream(), object); } } catch (Exception e) { throw new ServletException(e); } }
From source file:com.collective.celos.servlet.JSONSlotStateServlet.java
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException { String id = req.getParameter(CelosClient.ID_PARAM); try {/* w w w . j a v a 2 s . c o m*/ if (id == null) { res.sendError(HttpServletResponse.SC_BAD_REQUEST, CelosClient.ID_PARAM + " parameter missing."); return; } SlotID slotID = new SlotID(new WorkflowID(id), getRequestTime(req)); try (StateDatabaseConnection connection = getStateDatabase().openConnection()) { SlotState slotState = connection.getSlotState(slotID); if (slotState == null) { res.sendError(HttpServletResponse.SC_NOT_FOUND, "Slot not found: " + id); } else { ObjectNode object = slotState.toJSONNode(); writer.writeValue(res.getOutputStream(), object); } } } catch (Exception e) { throw new ServletException(e); } }
From source file:dk.clarin.tools.rest.upload.java
public void init(ServletConfig config) throws ServletException { InputStream fis = config.getServletContext().getResourceAsStream("/WEB-INF/classes/properties.xml"); ToolsProperties.readProperties(fis); BracMat = new bracmat(ToolsProperties.bootBracmat); super.init(config); destinationDir = new File(ToolsProperties.documentRoot /*+ ToolsProperties.stagingArea*/); if (!destinationDir.isDirectory()) { throw new ServletException("Trying to set \"" + ToolsProperties.documentRoot /*+ ToolsProperties.stagingArea*/ + "\" as directory for temporary storing intermediate and final results, but this is not a valid directory."); }/*from w ww . j a v a 2s. co m*/ }
From source file:com.omsalung.service.filter.JWTFilter.java
private String getToken(HttpServletRequest httpRequest) throws ServletException { String token = null;//w w w . j a v a 2 s .co m final String authorizationHeader = httpRequest.getHeader("authorization"); if (authorizationHeader == null) { throw new ServletException("Unauthorized: No Authorization header was found"); } String[] parts = authorizationHeader.split(" "); if (parts.length != 2) { throw new ServletException("Unauthorized: Format is Authorization: Bearer [token]"); } String scheme = parts[0]; String credentials = parts[1]; Pattern pattern = Pattern.compile("^Bearer$", Pattern.CASE_INSENSITIVE); if (pattern.matcher(scheme).matches()) { token = credentials; } return token; }
From source file:de.betterform.agent.web.servlet.XFormsRequestURIServlet.java
/** * This servlet uses the requestURI to locate and parse a XForms document for processing. The actual processing * is done by XFormsFilter. The parsed DOM of the document is passed as a request param to the filter. * * @param request servlet request//from ww w .jav a 2s . c om * @param response servlet response * @throws javax.servlet.ServletException * @throws java.io.IOException */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.debug("hit XFormsRequestURIServlet"); request.setCharacterEncoding("UTF-8"); WebUtil.nonCachingResponse(response); Document doc; //locate it String formRequestURI = request.getRequestURI().substring(request.getContextPath().length() + 1); String realPath = null; try { realPath = WebFactory.getRealPath(formRequestURI, getServletContext()); } catch (XFormsConfigException e) { throw new ServletException(e); } File xfDoc = new File(realPath); if (request.getHeader("betterform-internal") != null) { BufferedInputStream in = new BufferedInputStream(new FileInputStream(xfDoc)); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); int read; while ((read = in.read()) > -1) { out.write(read); } out.flush(); } else { try { //parse it doc = DOMUtil.parseXmlFile(xfDoc, true, false); } catch (ParserConfigurationException e) { throw new ServletException(e); } catch (SAXException e) { throw new ServletException(e); } request.setAttribute(WebFactory.XFORMS_NODE, doc); //do the Filter twist response.getOutputStream().close(); } }