List of usage examples for javax.servlet ServletException ServletException
public ServletException(Throwable rootCause)
From source file:FileUploading.UploadServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { throw new ServletException("Get Method used with " + getClass().getName() + " : POST method required ."); }
From source file:ResourceServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //get web.xml for display by a servlet String file = "/WEB-INF/web.xml"; URL url = null;//from ww w. ja va2 s .c o m URLConnection urlConn = null; PrintWriter out = null; BufferedInputStream buf = null; try { out = response.getWriter(); url = getServletContext().getResource(file); //set response header response.setContentType("text/xml"); urlConn = url.openConnection(); //establish connection with URL presenting web.xml urlConn.connect(); buf = new BufferedInputStream(urlConn.getInputStream()); int readBytes = 0; while ((readBytes = buf.read()) != -1) out.write(readBytes); } catch (MalformedURLException mue) { throw new ServletException(mue.getMessage()); } catch (IOException ioe) { throw new ServletException(ioe.getMessage()); } finally { if (out != null) out.close(); if (buf != null) buf.close(); } }
From source file:gov.nih.nci.cabio.portal.portlet.AppLoadPlugin.java
public void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException { log.info("Init caBIO Portlet"); try {/* w ww .j a va2 s . c o m*/ actionServlet.getServletContext().setAttribute("globalQueries", new GlobalQueries()); actionServlet.getServletContext().setAttribute("objectConfig", new CannedObjectConfig()); } catch (Exception e) { log.fatal("Failed to load canned object configuration, cannot proceed.", e); throw new ServletException("Failed to load data for caBIO Portlet"); } }
From source file:com.nec.nsgui.exception.NSExceptionPlugIn.java
/** * Firstly Get the ExcptiongConf Object according to the exception config file; * @param servlet The ActionServlet making this request * @param config Module config of the module *///from w ww .j ava 2 s . com public void init(ActionServlet servlet, ModuleConfig config) throws ServletException { ExceptionConf exceptionConf = new ExceptionConf(); if (confFile == null || confFile.equals("")) { throw new ServletException("The conf file of NSExceptionPlugIn has not been specified."); } try { String[] files = confFile.split(","); if (files != null) { for (int i = 0; i < files.length; i++) { InputStream input = servlet.getServletContext().getResourceAsStream(files[i].trim()); exceptionConf.addAll(parse(input)); } } ExceptionConfMap.getInstance().addExceptionConf(config.getPrefix(), exceptionConf); } catch (Exception ex) { throw new ServletException(ex); } }
From source file:com.msco.mil.client.com.sencha.gxt.examples.resources.server.JsonTreeServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try {/*from w w w . j a va 2 s . co m*/ String id = req.getParameter("id"); Folder folder = Folder.findFolder(id == null ? 1 : Integer.valueOf(id)); String xml = generateJson(folder); resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); out.println(xml); out.flush(); } catch (Exception e) { throw new ServletException(e); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.json.JsonProducer.java
/** * Process a list of Individuals into a JSON array that holds the Names and URIs. *///w ww. j ava2s.co m protected JSONArray individualsToJson(List<Individual> individuals) throws ServletException { try { JSONArray ja = new JSONArray(); for (Individual ent : individuals) { JSONObject entJ = new JSONObject(); entJ.put("name", ent.getName()); entJ.put("URI", ent.getURI()); ja.put(entJ); } return ja; } catch (JSONException ex) { throw new ServletException("could not convert list of Individuals into JSON: " + ex); } }
From source file:eu.hydrologis.stage.geopaparazzi.servlets.ProjectDownloadServiceHandler.java
@Override public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String authHeader = req.getHeader("Authorization"); String[] userPwd = StageUtils.getUserPwdWithBasicAuthentication(authHeader); if (userPwd == null || !LoginChecker.isLoginOk(userPwd[0], userPwd[1])) { throw new ServletException("No permission!"); }/*from w w w . j ava 2s .c o m*/ // userPwd = new String[]{"testuser"}; Object projectIdObj = req.getParameter("id"); if (projectIdObj != null) { String projectId = (String) projectIdObj; File geopaparazziFolder = StageWorkspace.getInstance().getGeopaparazziFolder(userPwd[0]); File newGeopaparazziFile = new File(geopaparazziFolder, projectId); byte[] data = IOUtils.toByteArray(new FileInputStream(newGeopaparazziFile)); DownloadService service = new DownloadService(data, newGeopaparazziFile.getName()); service.register(); resp.sendRedirect(resp.encodeRedirectURL(service.getURL())); } else { throw new ServletException("No project id provided."); } }
From source file:de.dominikschadow.javasecurity.csrf.CSRFTokenHandler.java
public static boolean isValid(HttpServletRequest request) throws ServletException, NoSuchAlgorithmException, NoSuchProviderException { if (request.getSession(false) == null) { throw new ServletException(MISSING_SESSION); }//ww w. j av a 2 s . co m return StringUtils.equals(getToken(request.getSession(false)), request.getParameter(CSRF_TOKEN)); }
From source file:at.molindo.notify.servlet.NotifyFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { _notifyFilterBean = findNotifyFilterBean(findWebApplicationContext(filterConfig.getServletContext())); if (_notifyFilterBean == null) { throw new ServletException("couldn't find NotifyFilterBean"); }//from www. j av a2 s . c o m }
From source file:edu.cornell.mannlib.vitro.webapp.search.controller.UpdateUrisInIndex.java
/** * Web service for update in search index of a list of URIs. * //from ww w . ja v a 2s . c om * @throws IOException */ protected int doUpdateUris(HttpServletRequest req, SearchIndexer indexer) throws ServletException, IOException { Map<String, List<FileItem>> map = new VitroRequest(req).getFiles(); if (map == null) { throw new ServletException("Expected Multipart Content"); } Charset enc = getEncoding(req); int uriCount = 0; for (String name : map.keySet()) { for (FileItem item : map.get(name)) { log.debug("Found " + item.getSize() + " byte file for '" + name + "'"); uriCount += processFileItem(indexer, item, enc); } } return uriCount; }