List of usage examples for javax.servlet ServletException ServletException
public ServletException(Throwable rootCause)
From source file:com.w4t.engine.W4TDelegate.java
/** Initialize global variables */ public void init(final ServletConfig config) throws ServletException { super.init(config); ServiceManager.setHandler(new DispatchHandler()); LifeCycleServiceHandler.lifeCycleRunner = new LifeCycleRunner(); try {/*ww w . jav a2 s . com*/ createImageCacheInstance(); } catch (Exception e) { throw new ServletException(e); } startRegistrySkimmer(); }
From source file:org.openmrs.module.bom.web.controller.ManageBillsController.java
@RequestMapping(value = "/module/bom/manageBills", method = RequestMethod.GET) protected void renderDashboard(ModelMap map) throws Exception { int patientId = 71158; //This should be a parameter. (@RequestParam(required = true, value = "patientId") Integer patientId, ModelMap map) // get the patient PatientService ps = Context.getPatientService(); Patient patient = null;/*w ww .ja va 2s. co m*/ try { patient = ps.getPatient(patientId); } catch (ObjectRetrievalFailureException noPatientEx) { log.warn("There is no patient with id: '" + patientId + "'", noPatientEx); } if (patient == null) throw new ServletException("There is no patient with id: '" + patientId + "'"); log.debug("patient: '" + patient + "'"); map.put("patient", patient); // empty objects used to create blank template in the view map.put("emptyIdentifier", new PatientIdentifier()); map.put("emptyName", new PersonName()); map.put("emptyAddress", new PersonAddress()); }
From source file:com.groupdocs.ui.ViewerUtils.java
public static FileData factoryFileData(String path) throws ServletException { DocumentInfoContainer docInfo = null; try {/* w w w . j ava 2 s . c o m*/ docInfo = ViewerUtils.getViewerHtmlHandler().getDocumentInfo(new DocumentInfoOptions(path)); } catch (Exception x) { throw new ServletException(x); } int maxWidth = 0; int maxHeight = 0; for (PageData pageData : docInfo.getPages()) { if (pageData.getHeight() > maxHeight) { maxHeight = pageData.getHeight(); maxWidth = pageData.getWidth(); } } FileData fileData = new FileData(); fileData.setDateCreated(new Date()); fileData.setDateModified(docInfo.getLastModificationDate()); fileData.setPageCount(docInfo.getPages().size()); fileData.setPages(docInfo.getPages()); fileData.setMaxWidth(maxWidth); fileData.setMaxHeight(maxHeight); return fileData; }
From source file:fm.last.citrine.web.DisplayTaskRunMessageController.java
/** * Retrieves the task run ID from the passed request. * /* w w w. j a v a2 s. c o m*/ * @param request Request. * @return The task run ID set in the request. * @throws ServletException If the task run ID parameter was not set on the request. */ private long getTaskRunId(HttpServletRequest request) throws ServletException { String idString = request.getParameter(PARAM_TASK_RUN_ID); if (idString != null) { return Long.parseLong(idString); } else { throw new ServletException(PARAM_TASK_RUN_ID + " required"); } }
From source file:org.sakaiproject.metaobj.utils.mvc.impl.servlet.AbstractFormController.java
public ModelAndView processCancel(Map request, Map session, Map application, Object command, Errors errors) throws Exception { throw new ServletException( "Wizard form controller class [" + getClass().getName() + "] does not support a cancel operation"); }
From source file:org.metis.MetisServlet.java
/** * This method will be invoked after all bean properties have been set and * the WebApplicationContext has been loaded. * //from ww w . j a va 2 s . c om * @throws ServletException * in case of an initialization exception */ @Override protected void initFrameworkServlet() throws ServletException { super.initFrameworkServlet(); if ((rdbs == null || rdbs.isEmpty()) && (pdbs == null || pdbs.isEmpty())) { throw new ServletException(getServletConfig().getServletName() + ": There are neither resource nor pusher" + "beans defined for this web application context"); } for (WdsResourceBean rdb : rdbs.values()) { if (!rdb.isDbConnectionAcquired()) { LOG.error(getServletConfig().getServletName() + ": this RDB was not able to get a " + "connection to its data source: " + rdb.getBeanName()); throw new ServletException(getServletConfig().getServletName() + ": this RDB was not able to get a " + "connection to its data source: " + rdb.getBeanName()); } } for (PusherBean pdb : pdbs.values()) { if (!pdb.isDbConnectionAcquired()) { LOG.error(getServletConfig().getServletName() + ": this PUSHER was not able to get a " + "connection to its data source: " + pdb.getBeanName()); throw new ServletException( getServletConfig().getServletName() + ": this PUSHER was not able to get a " + "connection to its data source: " + pdb.getBeanName()); } // assign this servelt's name to the PDB pdb.setServletName(getServletName()); } }
From source file:edu.vt.middleware.ldap.servlets.CommonServlet.java
/** * Initialize this servlet.//from www .j a v a 2 s. c om * * @param config <code>ServletConfig</code> * * @throws ServletException if an error occurs */ public void init(final ServletConfig config) throws ServletException { super.init(config); String sessionManagerClass = getInitParameter(ServletConstants.SESSION_MANAGER); if (sessionManagerClass == null) { sessionManagerClass = ServletConstants.DEFAULT_SESSION_MANAGER; } if (this.logger.isDebugEnabled()) { this.logger.debug(ServletConstants.SESSION_MANAGER + " = " + sessionManagerClass); } try { this.sessionManager = (SessionManager) Class.forName(sessionManagerClass).newInstance(); } catch (ClassNotFoundException e) { if (this.logger.isErrorEnabled()) { this.logger.error("Could not find class " + sessionManagerClass, e); } throw new ServletException(e); } catch (InstantiationException e) { if (this.logger.isErrorEnabled()) { this.logger.error("Could not instantiate class " + sessionManagerClass, e); } throw new ServletException(e); } catch (IllegalAccessException e) { if (this.logger.isErrorEnabled()) { this.logger.error("Could not access class " + sessionManagerClass, e); } throw new ServletException(e); } String sessionId = getInitParameter(ServletConstants.SESSION_ID); if (sessionId == null) { sessionId = ServletConstants.DEFAULT_SESSION_ID; } if (this.logger.isDebugEnabled()) { this.logger.debug(ServletConstants.SESSION_ID + " = " + sessionId); } this.sessionManager.setSessionId(sessionId); String invalidateSession = getInitParameter(ServletConstants.INVALIDATE_SESSION); if (invalidateSession == null) { invalidateSession = ServletConstants.DEFAULT_INVALIDATE_SESSION; } if (this.logger.isDebugEnabled()) { this.logger.debug(ServletConstants.INVALIDATE_SESSION + " = " + invalidateSession); } this.sessionManager.setInvalidateSession(Boolean.valueOf(invalidateSession).booleanValue()); }
From source file:org.iwethey.forums.web.json.FastJsonView.java
public void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws ServletException { try {/* w w w . j a va 2 s . co m*/ OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream()); Object data = model.get("json"); Object serTmp = model.get("serializer"); JacksonSerializer ser = null; if (serTmp != null && JacksonSerializer.class.isAssignableFrom(serTmp.getClass())) { ser = (JacksonSerializer) serTmp; } else { ser = new JacksonSerializer(); } if (data != null) { ser.serialize(data, out); } out.flush(); } catch (IOException ie) { throw new ServletException(ie); } catch (JsonException e) { throw new ServletException(e); } }
From source file:org.accelerators.activiti.servlet.SpringApplicationServlet.java
@SuppressWarnings("unchecked") @Override//w w w . java 2 s .co m public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); applicationBean = servletConfig.getInitParameter("applicationBean"); if (applicationBean == null) { throw new ServletException("ApplicationBean not specified in servlet parameters"); } applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletConfig.getServletContext()); applicationClass = (Class<? extends Application>) applicationContext.getType(applicationBean); }
From source file:cpabe.controladores.UploadDecriptacaoServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String fileName = request.getParameter("fileName"); if (fileName == null || fileName.equals("")) { throw new ServletException("O nome do arquivo no pode ser null ou vazio."); }/* ww w. jav a 2 s . c o m*/ File file = new File(request.getServletContext().getAttribute("FILES_DIR") + File.separator + fileName); if (!file.exists()) { throw new ServletException("O arquivo desejado no existe no Servidor."); } System.out.println("File location on server::" + file.getAbsolutePath()); ServletContext ctx = getServletContext(); InputStream fis = new FileInputStream(file); String mimeType = ctx.getMimeType(file.getAbsolutePath()); response.setContentType(mimeType != null ? mimeType : "application/octet-stream"); response.setContentLength((int) file.length()); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); ServletOutputStream os = response.getOutputStream(); byte[] bufferData = new byte[1024]; int read = 0; while ((read = fis.read(bufferData)) != -1) { os.write(bufferData, 0, read); } os.flush(); os.close(); fis.close(); System.out.println("File downloaded at client successfully"); }