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(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.

Usage

From source file:org.red5.server.net.servlet.StatisticsServlet.java

/** {@inheritDoc} */
@Override//from  w ww  .j  a v  a2 s .co m
public void init() throws ServletException {
    webAppCtx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    if (webAppCtx == null) {
        webAppCtx = (WebApplicationContext) getServletContext()
                .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    }
    if (webAppCtx == null) {
        throw new ServletException("No web application context found.");
    }

    webContext = (IContext) webAppCtx.getBean("web.context");

    // Register handlers in XML-RPC server
    server.addHandler("scopes", new XmlRpcScopeStatistics(webContext.getGlobalScope()));
}

From source file:psiprobe.ProbeServlet.java

/**
 * Associates the {@link Wrapper} with the {@link ContainerWrapperBean}.
 * //from  w  w w. j  av a 2  s .com
 * @param config this servlet's configuration and initialization parameters
 * @throws ServletException if the wrapper is null or another servlet-interrupting error occurs
 */
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    if (wrapper != null) {
        getContainerWrapperBean().setWrapper(wrapper);
    } else {
        throw new ServletException("Wrapper is null");
    }
}

From source file:com.woonoz.proxy.servlet.ProxyServlet.java

@Override
public void init(ServletConfig servletConfig) throws ServletException {
    try {//from  w  w  w  .  java 2 s. co  m
        ProxyServletConfig config = new ProxyServletConfig(servletConfig);
        init(config);
    } catch (IOException e) {
        throw new ServletException(e);
    }
}

From source file:net.ontopia.topicmaps.nav2.servlets.AutoSuggestServlet.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    response.setContentType("text/plain; charset=utf-8");

    String tmid = request.getParameter("tm");
    if (tmid == null)
        throw new ServletException("Parameter tm is not given.");
    String term = request.getParameter("term");
    if (term == null)
        throw new ServletException("Parameter term is not given.");

    TopicMapStoreIF store = TopicMaps.createStore(tmid, true);

    if (store instanceof net.ontopia.topicmaps.impl.basic.InMemoryTopicMapStore)
        term = term + '*';

    try {//  ww  w  .j  a  v a2s  . c o m
        QueryProcessorIF qp = QueryUtils.getQueryProcessor(store.getTopicMap());
        QueryResultIF qr = qp.execute(query, Collections.singletonMap("TERM", term));
        System.out.println("query: " + query);
        PrintWriter w = response.getWriter();
        w.write("{ results: [\n");
        int count = 0;
        while (qr.next()) {
            if (count > limit)
                break;
            if (count > 0)
                w.write(",\n");
            TopicIF topic = (TopicIF) qr.getValue(0);
            String desc = (String) qr.getValue(1);
            w.write("    { id: \"");
            w.write(topic.getObjectId());
            w.write("\", value: \"");
            w.write(escape(TopicStringifiers.toString(topic)));
            w.write("\", info: \"");
            w.write((desc == null ? "" : escape(desc)));
            w.write("\" }");
            count++;
        }
        w.write("\n] }\n");

    } catch (Exception e) {
        throw new ServletException(e);
    } finally {
        store.close();
    }
}

From source file:de.elatexam.UploadTaskdefServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    UserService userService = UserServiceFactory.getUserService();
    if (!userService.isUserLoggedIn()) {
        resp.sendRedirect("/");
    } else {/* w  w w  . j a  v a  2s  . c om*/
        try {
            ServletFileUpload upload = new ServletFileUpload();

            FileItemIterator iterator = upload.getItemIterator(req);
            while (iterator.hasNext()) {
                FileItemStream item = iterator.next();

                long handle = System.nanoTime();
                DataStoreTaskFactory.getInstance().storeTaskDef(item.openStream(), handle,
                        userService.getCurrentUser());
            }
        } catch (Exception ex) {
            throw new ServletException(ex);
        }
        resp.sendRedirect("/");
    }

}

From source file:com.collective.celos.servlet.RegisterServlet.java

protected void doPut(HttpServletRequest req, HttpServletResponse res) throws ServletException {
    try {//from w ww . j a v a 2  s.c om
        BucketID bucket = getRequestBucketID(req);
        RegisterKey key = getRequestKey(req);
        JsonNode value = Util.JSON_READER
                .readTree(new InputStreamReader(req.getInputStream(), StandardCharsets.UTF_8));
        try (StateDatabaseConnection connection = getStateDatabase().openConnection()) {
            connection.putRegister(bucket, key, value);
        }
    } catch (Exception e) {
        throw new ServletException(e);
    }
}

From source file:com.bluexml.xforms.actions.EditFormAction.java

/**
 * Edits the item that's active among the items selected on a selection widget.
 * //  w  w  w  . j  a  va  2  s .c o m
 * @throws ServletException
 */
@Override
protected void edit() throws ServletException {
    // retrieve id
    AlfrescoController alfController = AlfrescoController.getInstance();
    EditNodeBean editBean = alfController.getEditNodeAndReset(node);
    if (editBean == null) {
        throw new ServletException("No edit id found in the form instance.");
    }
    String dataId = editBean.getDataId();

    PageInfoBean pageBean = new PageInfoBean();
    String targetForms = requestParameters.get(MsgId.INT_ACT_PARAM_ANY_DATATYPE.getText());
    // String formTypeHint = requestParameters.get(MsgId.INT_ACT_PARAM_ANY_HINT.getText()); 
    // FIXME: do we need formTypeHint ?
    pageBean.setDataId(dataId);
    pageBean.setLanguage(navigationPath.peekCurrentPage().getLanguage());

    // set the form type, form name and data type
    resolvePageInfo(pageBean, editBean, targetForms);

    navigationPath.setCurrentPage(pageBean);
}

From source file:cn.vlabs.umt.ui.servlet.AppProxyServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String act = request.getParameter("act");
    try {//from  w  ww.j a va 2  s.  c o m
        if (act != null) {
            if (validRandom(request)) {
                genHalfProxy(request, response);
            }
        } else {
            sendRandom(request, response);
        }
    } catch (DecodingException e) {
        throw new ServletException(e);
    }
}

From source file:kurosawa.dictionary.main.server.DictionaryServiceImpl.java

public void init() throws ServletException {
    try {/*from  ww  w  .j  a v  a 2s .  co m*/
        log.info("WebApplicationContextUtils");
        // applicationContext.xml????Bean???
        // ??? Autowire?
        WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext())
                .getAutowireCapableBeanFactory().autowireBean(this);
        log.info("init WebApplicationContextUtils end");
    } catch (IllegalStateException ex) {
        // ?????web.xml????
        throw new ServletException("Couldn't get Spring's WebApplicationContext. "
                + "Please check whether ContextLoaderListener exists " + "in your web.xml.");
    }
}

From source file:net.sf.sripathi.ws.mock.servlet.MockServlet.java

/**
 * Initalize the servlet.//from w  ww  . j  a  v a  2 s .  c  o m
 */
@Override
public void init() throws ServletException {
    super.init();

    //Check if there is a valid workspace set configured in the init param
    workingDirectory = super.getServletContext().getInitParameter("WORKSPACE_DIR");

    //If init param is not set use default
    if (!StringUtil.isValid(workingDirectory)) {
        workingDirectory = getServletContext().getRealPath("/workspace");
    }

    workingDirectory = workingDirectory.replace('\\', '/');

    if (!new File(workingDirectory).exists()) {
        throw new ServletException("Unable to access specified path - " + workingDirectory + ". If workspace"
                + " is specified in web.xml please make sure the specified folder exists and access is provided.");
    }

    DomainFactory.getInstance().setWorkingDir(workingDirectory);

    try {
        RollingFileAppender appender = new RollingFileAppender(new PatternLayout("| %d | %m %n"),
                workingDirectory + "/Mock.log", false);
        appender.setMaxFileSize("" + 1024 * 512);
        Logger.getLogger(MockServlet.class).addAppender(appender);
    } catch (Exception e) {
        e.printStackTrace();
    }
}