List of usage examples for javax.servlet ServletException ServletException
public ServletException(Throwable rootCause)
From source file:cc.aileron.wsgi.WsgiHttpFilter.java
@Override public void init(final FilterConfig config) throws ServletException { context = config.getServletContext(); try {/*from ww w . j a v a 2 s. c o m*/ appendResourceLoader(context.getRealPath("/")); model = new WsgiModel(config.getInitParameter("environment")); } catch (final Exception e) { logger.error("init-error", e); throw new ServletException(e); } }
From source file:net.scran24.admin.server.services.SurveyManagementServiceImpl.java
@Override public void init() throws ServletException { try {//from w ww.j ava2s. c o m Injector injector = (Injector) this.getServletContext().getAttribute("intake24.injector"); dataStore = injector.getInstance(DataStore.class); } catch (Throwable e) { throw new ServletException(e); } }
From source file:com.github.matthesrieke.simplebroker.SimpleBrokerServlet.java
public void init() throws ServletException { super.init(); try {//from w w w . j av a 2 s . c o m this.allowedProducers = FileUtil.readConfigFilePerLine(PRODUCERS_FILE); } catch (IOException e) { throw new ServletException(e); } startWatchThread(); }
From source file:com.controlj.green.istat.web.BookmarkServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //System.out.println("Area Servlet called at:"+new Date()); resp.setHeader("Expires", "Wed, 01 Jan 2003 12:00:00 GMT"); resp.setHeader("Cache-Control", "no-cache"); ServletOutputStream out = resp.getOutputStream(); try {/*from w w w . j av a 2s .c om*/ writeLocations(out, req.getParameterValues("bookmarks"), req); } catch (Exception e) { Logging.LOGGER.println("Unexpected exception:"); e.printStackTrace(Logging.LOGGER); throw new ServletException(e); } /* out.println("["); out.println("{ display:'Main Conf Room', id:'mainconf'},"); out.println("{ display:'Board Room', id:'boardroom'},"); out.println("{ display:'Room 235', id:'room235'}"); out.println("]"); */ }
From source file:org.ws13.vaadin.osgi.dm.app.SpringApplicationServlet.java
/** * Get the application bean in Spring's context. * /*from w ww. j a v a 2 s. c om*/ * @see AbstractApplicationServlet#getNewApplication(HttpServletRequest) */ @Override protected Application getNewApplication(HttpServletRequest request) throws ServletException { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); if (wac == null) { throw new ServletException("Cannot get an handle on Spring's context. Is Spring running?" + "Check there's an org.springframework.web.context.ContextLoaderListener configured."); } String[] beanDefinitionNames = wac.getBeanDefinitionNames(); for (String string : beanDefinitionNames) { System.out.println("SpringApplicationServlet.getNewApplication() ->" + string); } Application bean = wac.getBean(name, Application.class); if (!(bean instanceof Application)) { throw new ServletException("Bean " + name + " is not of expected class Application"); } return bean; }
From source file:org.fusesource.restygwt.server.complex.DTOTypeResolverServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { DTO1 one = new DTO1(); one.name = "Fred Flintstone"; one.size = 1024;/*from w w w.j a va 2s .c o m*/ DTO2 two = new DTO2(); two.name = "Barney Rubble"; two.foo = "schmaltzy"; DTO2 three = new DTO2(); three.name = "BamBam Rubble"; three.foo = "dorky"; resp.setContentType("application/json"); ObjectMapper om = new ObjectMapper(); try { ObjectWriter writer = om.writer() .withType(om.constructType(getClass().getMethod("prototype").getGenericReturnType())); writer.writeValue(resp.getOutputStream(), Lists.newArrayList(one, two, three)); } catch (Exception e) { throw new ServletException(e); } }
From source file:be.fedict.eid.applet.beta.webapp.JAASLoginFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { LOG.debug("doFilter"); HttpServletRequest httpRequest = (HttpServletRequest) request; HttpSession httpSession = httpRequest.getSession(); Credentials credentials = (Credentials) httpSession.getAttribute("org.jboss.seam.security.credentials"); LoginContext loginContext = null; String username = credentials.getUsername(); if (null != username) { CallbackHandler callbackHandler = new UsernamePasswordHandler(username, username); try {//w w w . j ava 2s . com loginContext = new LoginContext("client-login", callbackHandler); loginContext.login(); } catch (LoginException e) { throw new ServletException("JAAS login error"); } } try { chain.doFilter(request, response); } finally { if (null != loginContext) { try { loginContext.logout(); } catch (LoginException e) { throw new ServletException("JAAS logout error"); } } } }
From source file:edu.umn.msi.tropix.transfer.http.server.embedded.ControllerHandlerImpl.java
public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { try {/*from ww w . j ava 2 s . com*/ controller.handleRequest(request, response); } catch (final IOException e) { ExceptionUtils.logQuietly(LOG, e, "IOException in transfer controller."); throw e; } catch (final Exception e) { ExceptionUtils.logQuietly(LOG, e, "Generic exception in transfer controller."); throw new ServletException(e); } }
From source file:hudson.security.UnwrapSecurityExceptionFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {/*from w w w .j av a 2s.c o m*/ chain.doFilter(request, response); } catch (ServletException e) { Throwable t = e.getRootCause(); if (t instanceof JellyTagException) { JellyTagException jte = (JellyTagException) t; Throwable cause = jte.getCause(); if (cause instanceof AcegiSecurityException) { AcegiSecurityException se = (AcegiSecurityException) cause; throw new ServletException(se); } } throw e; } }
From source file:DbMetaServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { String sql = "select * from aTable"; Connection conn = null;/*from w w w. jav a 2s. c om*/ Statement stmt = null; ResultSet rs = null; ResultSetMetaData rsm = null; response.setContentType("text/html"); java.io.PrintWriter out = response.getWriter(); out.println("<html><head><title>Discover a ResultSet</title></head><body>"); out.println("<h2>Here is Info about the returned ResultSet</h2>"); out.println("<table border='1'><tr>"); try { //Get a connection from the pool conn = pool.getConnection(); //Create a Statement with which to run some SQL stmt = conn.createStatement(); //Execute the SQL rs = stmt.executeQuery(sql); //Get a ResultSetMetaData object from the ResultSet rsm = rs.getMetaData(); int colCount = rsm.getColumnCount(); //print column names printMeta(rsm, "name", out, colCount); //print column index printMeta(rsm, "index", out, colCount); //print column type printMeta(rsm, "column type", out, colCount); //print column display size printMeta(rsm, "column display", out, colCount); } catch (Exception e) { throw new ServletException(e.getMessage()); } finally { try { stmt.close(); conn.close(); } catch (SQLException sqle) { } } out.println("</table></body></html>"); out.close(); }