List of usage examples for javax.servlet ServletException ServletException
public ServletException(String message, Throwable rootCause)
From source file:com.example.appengine.mailjet.MailjetServlet.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String recipient = req.getParameter("to"); String sender = req.getParameter("from"); MailjetRequest email = new MailjetRequest(Email.resource).property(Email.FROMEMAIL, sender) .property(Email.FROMNAME, "pandora").property(Email.SUBJECT, "Your email flight plan!") .property(Email.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!") .property(Email.HTMLPART,//from w ww . j av a 2 s . c o m "<h3>Dear passenger, welcome to Mailjet!</h3><br/>May the delivery force be with you!") .property(Email.RECIPIENTS, new JSONArray().put(new JSONObject().put("Email", recipient))); try { // trigger the API call MailjetResponse response = client.post(email); // Read the response data and status resp.getWriter().print(response.getStatus()); resp.getWriter().print(response.getData()); } catch (MailjetException e) { throw new ServletException("Mailjet Exception", e); } catch (MailjetSocketTimeoutException e) { throw new ServletException("Mailjet socket timed out", e); } }
From source file:com.example.managedvms.mailjet.MailjetServlet.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String recipient = req.getParameter("to"); String sender = req.getParameter("from"); MailjetRequest email = new MailjetRequest(Email.resource).property(Email.FROMEMAIL, sender) .property(Email.FROMNAME, "pandora").property(Email.SUBJECT, "Your email flight plan!") .property(Email.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!") .property(Email.HTMLPART,//ww w. ja va 2 s .c o m "<h3>Dear passenger, welcome to Mailjet!</h3><br/>May the delivery force be with you!") .property(Email.RECIPIENTS, new JSONArray().put(new JSONObject().put("Email", recipient))); try { // trigger the API call MailjetResponse response = client.post(email); // Read the response data and status resp.getWriter().print(response.getStatus()); resp.getWriter().print(response.getData()); } catch (MailjetException e) { throw new ServletException("Mailjet Exception", e); } }
From source file:com.marvelution.hudson.plugins.apiv2.servlet.filter.HudsonAPIV2ServletFilter.java
/** * {@inheritDoc}// w ww.j a v a2 s .c om */ @Override public void init(FilterConfig filterConfig) throws ServletException { try { final HudsonAPIV2FilterConfig restFilterConfig = new HudsonAPIV2FilterConfig(filterConfig); restServlet = new HudsonRestServletForFilter(restFilterConfig); restServlet.init(new HudsonAPIV2ServletConfig(restFilterConfig)); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed to create HudsonRestFilterConfig", e); throw new ServletException("Failed to create HudsonRestFilterConfig", e); } }
From source file:com.thoughtworks.go.server.web.ConfigValidityFilter.java
private boolean licenseValid(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException { try {//from w w w. j a v a2 s . c o m return this.licenseInterceptor.preHandle(httpServletRequest, httpServletResponse, null); } catch (Exception e) { throw new ServletException("Exception while verifying license", e); } }
From source file:com.composum.osgi.core.test.httpinterface.TestExecutorServlet.java
/** * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from w w w. j a v a 2 s. co m*/ @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final List<Result> runTests = this.testExecutorService.runTests(); final JSONWriter jsonWriter = new org.json.JSONWriter(resp.getWriter()); try { JSONWriter tests = jsonWriter.object().key("tests").array(); for (final Result result : runTests) { final String name = result.getDescription().getDisplayName(); final boolean success = result.isSuccess(); final Failure failure = result.getFailure(); final String message = success ? "ok" : failure.getMessage(); final String trace = success ? "" : failure.getTrace(); tests = tests.object().key("name").value(name).key("success").value(success).key("message") .value(message).key("trace").value(trace).endObject(); } tests.endArray().endObject(); } catch (final JSONException e) { throw new ServletException("error writing JSON response: " + e.getMessage(), e); } }
From source file:edu.umd.cs.submitServer.servlets.HandleBuildServerLogMessage.java
/** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to * post./*from www . j av a2 s .co m*/ * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { MultipartRequest multipartRequest = (MultipartRequest) request.getAttribute(MULTIPART_REQUEST); FileItem fileItem = null; LoggingEvent loggingEvent = null; ObjectInputStream in = null; try { fileItem = multipartRequest.getFileItem(); byte[] data = fileItem.get(); in = new ObjectInputStream(new ByteArrayInputStream(data)); loggingEvent = (LoggingEvent) in.readObject(); buildServerLogger.callAppenders(loggingEvent); } catch (ClassNotFoundException e) { throw new ServletException("Cannot find class: " + e.getMessage(), e); } finally { if (fileItem != null) fileItem.delete(); if (in != null) in.close(); } }
From source file:be.fedict.eid.idp.protocol.saml2.AbstractSAML2MetadataHttpServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); response.setContentType("application/samlmetadata+xml; charset=UTF-8"); IdentityProviderConfiguration configuration = IdentityProviderConfigurationFactory.getInstance(request); OutputStream outputStream = response.getOutputStream(); try {/*from w ww .ja v a 2s . c om*/ writeMetadata(request, configuration, outputStream); } catch (Exception e) { throw new ServletException("error: " + e.getMessage(), e); } }
From source file:com.qualogy.qafe.webservice.servlet.GenericWebServiceServlet.java
/** * Retrieves interface- and implementation class-names out of web.xml context parameter prefixed with "webservice." to add them as * webservices to the the WebServiceServer * //ww w.j a v a2 s . c om * @param servletConfig The ServletConfig of the webapplication * @see WebServiceServer */ @Override public void loadBus(ServletConfig servletConfig) throws ServletException { super.loadBus(servletConfig); // sets the busfactory needed to link the webapp url to the webservice System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, "org.apache.cxf.bus.CXFBusFactory"); Map<String, String> webservices = extractWebservices(servletConfig.getServletContext()); Bus bus = this.getBus(); BusFactory.setDefaultBus(bus); try { GenericWebServiceServer webServiceServer = createNewWebServiceServer(bus); // for(String serviceInterface : webservices.keySet()) { // webServiceServer.addService(serviceInterface, webservices.get(serviceInterface)); // } String webServiceInterface = webServiceServer.getInterface(); String webServiceImplementation = webServiceServer.getImplementation(); webServiceServer.addService(webServiceInterface, webServiceImplementation); } catch (Exception e) { logger.error("Error adding webservices", e); throw new ServletException("Error adding webservices", e); } }
From source file:com.revolsys.ui.web.config.JavaComponent.java
@Override public void includeComponent(final PageContext context) throws ServletException, IOException { Object instance;/* ww w . j a v a 2 s. c om*/ try { instance = this.componentClass.newInstance(); } catch (final Exception e) { throw new ServletException("Unable to create component instance", e); } try { final Iterator propertyNames = this.properties.keySet().iterator(); while (propertyNames.hasNext()) { final String propertyName = (String) propertyNames.next(); Object value = this.properties.get(propertyName); final WebUiContext niceContext = WebUiContext.get(); try { final Expression expression = JexlUtil.newExpression(value.toString()); if (expression != null) { value = niceContext.evaluateExpression(expression); } } catch (final Exception e) { throw new ServletException(e.getMessage(), e); } this.setPropertyMethod.invoke(instance, new Object[] { propertyName, value }); } } catch (final IllegalAccessException e) { log.error("Unable to set component properties", e.getCause()); throw new ServletException("Unable to set component properties", e); } catch (final InvocationTargetException e) { log.error("Unable to set component properties", e.getCause()); throw new ServletException("Unable to set component properties", e.getCause()); } try { final Writer out = context.getOut(); this.serializeMethod.invoke(instance, new Object[] { out }); } catch (final IllegalAccessException e) { throw new ServletException("Unable to serialize component", e); } catch (final InvocationTargetException e) { final Throwable cause = e.getCause(); log.error(cause.getMessage(), cause); if (cause instanceof IOException) { throw (IOException) cause; } throw new ServletException("Unable to serialize component", cause); } }
From source file:com.evon.injectTemplate.InjectTemplateFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { try {//from w w w . java 2 s . co m contentTypes = new ConcurrentHashMap<>(); templates = new ConcurrentHashMap<>(); TemplateConfig.load(filterConfig.getServletContext()); printConfig(); } catch (TemplateException e) { e.printStackTrace(); throw new ServletException(e.getMessage(), e); } }