Example usage for javax.servlet ServletException ServletException

List of usage examples for javax.servlet ServletException ServletException

Introduction

In this page you can find the example usage for javax.servlet ServletException ServletException.

Prototype


public ServletException(String message, Throwable rootCause) 

Source Link

Document

Constructs a new servlet exception when the servlet needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation, including a description message.

Usage

From source file:MakeApplicense.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {//from  w  ww  .  j av  a2  s  . c  o m
        CerateCert.toJustepBiz(request, response, URL);
    } catch (FileUploadException e) {
        throw new ServletException("License", e);
    }
}

From source file:gov.nih.nci.ncicb.cadsr.umlmodelbrowser.struts.common.SpringWebContextPlugIn.java

/**
 * Intializer. Instantiates a new object and adds it to the application context by key
 *
 * @param servlet The ActionServlet for our application
 * @param config  The ModuleConfig for our owning module
 * @throws ServletException if we cannot configure ourselves correctly
 *//*from w w w . jav a2 s. co m*/
public void init(ActionServlet servlet, ModuleConfig config) throws ServletException {

    this.servlet = servlet;
    try {
        ServletContext servletContext = servlet.getServletContext();
        SpringObjectLocatorImpl.applicationContext = WebApplicationContextUtils
                .getRequiredWebApplicationContext(servletContext);

    } catch (Exception e) {

        throw new ServletException("Could not initalize SpringObjectLocatorImpl.applicationContext", e);
    }

}

From source file:org.echocat.jemoni.jmx.support.SpringUtils.java

@Nonnull
public static <T> T getBeanFor(@Nonnull ServletContext servletContext, @Nonnull String beanName,
        @Nonnull Class<T> beanType) throws ServletException {
    final Object applicationContext = getApplicationContext(servletContext);
    final Object plainBean;
    try {/*from w w w. j  ava2  s. c  o  m*/
        plainBean = beanType.cast(GET_BEAN.invoke(applicationContext, beanName));
    } catch (Exception e) {
        final Throwable target = e instanceof InvocationTargetException
                ? ((InvocationTargetException) e).getTargetException()
                : null;
        if (target != null && target.getClass().getName().endsWith("NoSuchBeanDefinitionException")) {
            throw new ServletException("Could not find bean '" + beanName + "' at " + applicationContext + ".",
                    target);
        } else {
            throw new ServletException(
                    "Could not retrieve bean '" + beanName + "' from " + applicationContext + ".",
                    target != null ? target : e);
        }
    }
    if (!beanType.isInstance(plainBean)) {
        throw new ServletException("Could bean '" + beanName + "' is of type " + plainBean.getClass().getName()
                + " not of expected " + beanType.getName() + ".");
    }
    return beanType.cast(plainBean);
}

From source file:gov.nih.nci.ncicb.cadsr.common.struts.common.SpringWebContextPlugIn.java

/**
 * Intializer. Instantiates a new object and adds it to the application context by key
 *
 * @param servlet The ActionServlet for our application
 * @param config  The ModuleConfig for our owning module
 * @throws ServletException if we cannot configure ourselves correctly
 *//*from  ww  w  . j a  va2 s.  com*/
public void init(ActionServlet servlet, ModuleConfig config) throws ServletException {

    System.out.println(config.toString() + " init " + servlet.toString());
    this.servlet = servlet;
    try {
        ServletContext servletContext = servlet.getServletContext();
        SpringObjectLocatorImpl.applicationContext = WebApplicationContextUtils
                .getRequiredWebApplicationContext(servletContext);

    } catch (Exception e) {

        throw new ServletException("Could not initalize SpringObjectLocatorImpl.applicationContext", e);
    }

}

From source file:de.highbyte_le.weberknecht.Controller.java

/**
 * initialization of the controller//from  w w  w.j av a2s .  com
 */
@Override
public void init() throws ServletException {
    try {
        core = new ControllerCore(getServletContext());
    } catch (Exception e) {
        log.error("init() - Exception: " + e.getMessage(), e);
        throw new ServletException("internal error", e);
    }
}

From source file:com.google.u2f.gaedemo.servlets.RemoveTokenServlet.java

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
    User user = userService.getCurrentUser();
    String publicKey = req.getParameter("public_key");

    try {//from  w w  w.  j  av a  2  s  .  c o m
        u2fServer.removeSecurityKey(user.getUserId(), Hex.decodeHex(publicKey.toCharArray()));
    } catch (U2FException e) {
        throw new ServletException("couldn't remove U2F token", e);
    } catch (DecoderException e) {
        throw new ServletException("invalid public key", e);
    }

    JsonObject result = new JsonObject();
    result.addProperty("status", "ok");

    resp.setContentType("application/json");
    resp.getWriter().println(result.toString());
}

From source file:PostServlet.java

public void init() throws ServletException {
    try {//from  w  w w .  ja va  2 s  .  com
        nameXPath = XPath.newInstance("/search/name/text()");
        yearXPath = XPath.newInstance("/search/year/text()");
    } catch (JDOMException e) {
        throw new ServletException("Unable to create XPaths", e);
    }
    super.init();
}

From source file:com.amalto.core.servlet.LogViewerServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    String location = config.getInitParameter("logFile"); //$NON-NLS-1$
    try {/*  w ww.  j  a v  a  2 s.  com*/
        file = getLogFile(location);
    } catch (FileNotFoundException e) {
        throw new ServletException(e.getMessage(), e);
    }

    String defaultMaxLinesString = config.getInitParameter("maxLinesByChunk"); //$NON-NLS-1$
    defaultMaxLines = Integer.parseInt(defaultMaxLinesString);
    charset = config.getInitParameter("charset"); //$NON-NLS-1$
    if (charset == null) {
        charset = Charset.defaultCharset().name();
    }
}

From source file:com.omsalung.service.filter.JWTFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    String token = getToken((HttpServletRequest) request);

    try {/* w ww  .jav  a 2 s  .c o m*/
        Map<String, Object> decoded = jwtVerifier.verify(token);
        for (Map.Entry<String, Object> entry : decoded.entrySet()) {
            System.out.println("key : value --> { " + entry.getKey() + " : " + entry.getValue() + " }");
        }

        chain.doFilter(request, response);
    } catch (Exception e) {
        throw new ServletException("Unauthorized: Token validation failed", e);
    }
}

From source file:de.highbyte_le.weberknecht.ControllerFilter.java

/**
 * filter initialization/*from   w  w  w .  jav  a  2s . c o  m*/
 */
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    try {
        core = new ControllerCore(filterConfig.getServletContext());
    } catch (Exception e) {
        log.error("init() - Exception: " + e.getMessage(), e);
        throw new ServletException("internal error", e);
    }
}