Esempio n. 1
0
 public void service(ServletRequest request, ServletResponse response)
     throws IOException, ServletException {
   PrintWriter out = response.getWriter();
   response.setContentType("text/html");
   out.println(
       "<h1>company "
           + conf.getInitParameter("company")
           + " @ "
           + conf.getInitParameter("location")
           + "</h1>");
 }
Esempio n. 2
0
  public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    servletContext = servletConfig.getServletContext();

    try {
      SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
      con = scf.createConnection();
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Unable to open a SOAPConnection", e);
    }

    InputStream in = servletContext.getResourceAsStream("/WEB-INF/address.properties");

    if (in != null) {
      Properties props = new Properties();

      try {
        props.load(in);

        to = props.getProperty("to");
        data = props.getProperty("data");
      } catch (IOException ex) {
        // Ignore
      }
    }
  }
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    ctx = config.getServletContext();
    // set the response content type
    if (ctx.getInitParameter("responseContentType") != null) {
      responseContentType = ctx.getInitParameter("responseContentType");
    }
    // allow for resources dir over-ride at the xhp level otherwise allow
    // for the jmaki level resources
    if (ctx.getInitParameter("jmaki-xhp-resources") != null) {
      resourcesDir = ctx.getInitParameter("jmaki-xhp-resources");
    } else if (ctx.getInitParameter("jmaki-resources") != null) {
      resourcesDir = ctx.getInitParameter("jmaki-resources");
    }
    // allow for resources dir over-ride
    if (ctx.getInitParameter("jmaki-classpath-resources") != null) {
      classpathResourcesDir = ctx.getInitParameter("jmaki-classpath-resources");
    }

    String requireSessionString = ctx.getInitParameter("requireSession");
    if (requireSessionString != null) {
      if ("false".equals(requireSessionString)) {
        requireSession = false;
        getLogger().severe("XmlHttpProxyServlet: intialization. Session requirement disabled.");
      } else if ("true".equals(requireSessionString)) {
        requireSession = true;
        getLogger().severe("XmlHttpProxyServlet: intialization. Session requirement enabled.");
      }
    }
    String xdomainString = ctx.getInitParameter("allowXDomain");
    if (xdomainString != null) {
      if ("true".equals(xdomainString)) {
        allowXDomain = true;
        getLogger().severe("XmlHttpProxyServlet: intialization. xDomain access is enabled.");
      } else if ("false".equals(xdomainString)) {
        allowXDomain = false;
        getLogger().severe("XmlHttpProxyServlet: intialization. xDomain access is disabled.");
      }
    }
    // if there is a proxyHost and proxyPort specified create an HttpClient with the proxy
    String proxyHost = ctx.getInitParameter("proxyHost");
    String proxyPortString = ctx.getInitParameter("proxyPort");
    if (proxyHost != null && proxyPortString != null) {
      int proxyPort = 8080;
      try {
        proxyPort = new Integer(proxyPortString).intValue();
        xhp = new XmlHttpProxy(proxyHost, proxyPort);
      } catch (NumberFormatException nfe) {
        getLogger()
            .severe("XmlHttpProxyServlet: intialization error. The proxyPort must be a number");
        throw new ServletException(
            "XmlHttpProxyServlet: intialization error. The proxyPort must be a number");
      }
    } else {
      xhp = new XmlHttpProxy();
    }
  }
Esempio n. 4
0
 public void init(ServletConfig config)
   throws ServletException
 {
   com.caucho.server.webapp.WebApp webApp
     = (com.caucho.server.webapp.WebApp) config.getServletContext();
   super.init(config);
   com.caucho.jsp.TaglibManager manager = webApp.getJspApplicationContext().getTaglibManager();
   com.caucho.jsp.PageContextImpl pageContext = new com.caucho.jsp.PageContextImpl(webApp, this);
 }
Esempio n. 5
0
 /** Run once when servlet loaded. */
 public void init(ServletConfig config) throws ServletException {
   super.init(config);
   context = config.getServletContext();
   theApp = (LockssApp) context.getAttribute(ServletManager.CONTEXT_ATTR_LOCKSS_APP);
   servletMgr = (ServletManager) context.getAttribute(ServletManager.CONTEXT_ATTR_SERVLET_MGR);
   if (theApp instanceof LockssDaemon) {
     acctMgr = getLockssDaemon().getAccountManager();
   }
 }
Esempio n. 6
0
 @Override
 public void init(final ServletConfig config) throws ServletException {
   super.init(config);
   try {
     HTTPContext.init(config.getServletContext());
     final Enumeration<String> en = config.getInitParameterNames();
     while (en.hasMoreElements()) {
       String key = en.nextElement().toLowerCase(Locale.ENGLISH);
       final String val = config.getInitParameter(key);
       if (key.startsWith(Prop.DBPREFIX)) key = key.substring(Prop.DBPREFIX.length());
       if (key.equalsIgnoreCase(MainProp.USER[0].toString())) {
         user = val;
       } else if (key.equalsIgnoreCase(MainProp.PASSWORD[0].toString())) {
         pass = val;
       }
     }
   } catch (final IOException ex) {
     throw new ServletException(ex);
   }
 }
Esempio n. 7
0
 @Override
 public void init(final ServletConfig config) throws ServletException {
   super.init(config);
   try {
     HTTPContext.init(config.getServletContext());
     final Enumeration<String> en = config.getInitParameterNames();
     while (en.hasMoreElements()) {
       String key = en.nextElement().toLowerCase(Locale.ENGLISH);
       final String val = config.getInitParameter(key);
       if (key.startsWith(Prop.DBPREFIX)) key = key.substring(Prop.DBPREFIX.length());
       if (key.equalsIgnoreCase(StaticOptions.USER.name())) {
         username = val;
       } else if (key.equalsIgnoreCase(StaticOptions.PASSWORD.name())) {
         password = val;
       } else if (key.equalsIgnoreCase(StaticOptions.AUTHMETHOD.name())) {
         auth = AuthMethod.valueOf(val);
       }
     }
   } catch (final IOException ex) {
     throw new ServletException(ex);
   }
 }
 public void caucho_init(ServletConfig config) {
   try {
     com.caucho.server.webapp.WebApp webApp =
         (com.caucho.server.webapp.WebApp) config.getServletContext();
     init(config);
     if (com.caucho.jsp.JspManager.getCheckInterval() >= 0)
       _caucho_depends.setCheckInterval(com.caucho.jsp.JspManager.getCheckInterval());
     _jsp_pageManager = webApp.getJspApplicationContext().getPageManager();
     com.caucho.jsp.TaglibManager manager = webApp.getJspApplicationContext().getTaglibManager();
     com.caucho.jsp.PageContextImpl pageContext =
         new com.caucho.jsp.InitPageContextImpl(webApp, this);
   } catch (Exception e) {
     throw com.caucho.config.ConfigException.create(e);
   }
 }
Esempio n. 9
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    System.out.println("AddProjectServlet.doPost Entered...");

    init(response);
    PrintWriter out = response.getWriter();
    dataSource = (DataSource) request.getSession().getServletContext().getAttribute("DBCPool");
    baseurl = config.getServletContext().getInitParameter("baseurl"); // filesystem web-root
    parameterDAO.setDataSource(dataSource);
    pb.setParameterDAO(parameterDAO);
    filter.setParameterDAO(parameterDAO);

    System.out.println("AddProjectServlet.doPost done inits pb.set, filter.set...");

    if (ParameterDAO.parse(request.getParameter("clearmsgs"))) {
      msg = new StringBuffer();
    }

    String[] deleted = request.getParameterValues("delete");
    String addnew = request.getParameter("addnew");
    String updated = request.getParameter("updated");
    String undelete = request.getParameter("undelete");
    String searchbyx = request.getParameter("searchbyx");

    filter.setSearchString(StringUtils.trimToEmpty(request.getParameter("search")));
    String sortby = StringUtils.trimToEmpty(request.getParameter("sortby"));

    String order = "DESC";
    if (!ParameterDAO.parse(request.getParameter("order"))) order = "ASC";

    // if coming from addContacts, success or failure...
    if (ParameterDAO.parse(request.getAttribute("addcontacts"))
        || ParameterDAO.parse(request.getAttribute("addagencies"))
        || ParameterDAO.parse(request.getAttribute("uploadedfile"))) {
      msg.append(StringUtils.trimToEmpty((String) request.getAttribute("msg")));
    } else if (StringUtils.isNotBlank(filter.getSearchString())) {
      // triggers the simple search exclusive of any other action (safe from delete, by preceding in
      // if-then )
      // do absolutely nothing the search field will be populated just fine as expected.  Later, may
      // be add X number of projects
    } else if (deleted == null) {
      // System.out.println("AddProjectServlet.doPost Entered else if deleted == null");

      // coming from index.jsp
      if (ParameterDAO.parse(updated)) {
        addProject(request, response, true);
      } else if (ParameterDAO.parse(undelete)) {
        parameterDAO.unDeleteAllProjects();
      } else if (ParameterDAO.parse(addnew)) {
        addProject(request, response, false);
      } else if (ParameterDAO.parse(searchbyx)) {
        // we are just setting filter
        setProjectBean(request);
        filter = pb;
        System.out.println("Filter STARTS LIFE as = " + filter.toFilterString());
        // System.out.println("Filter Training INIT parsed as = " +
        // ParameterDAO.parse(filter.getTraining()));
        // System.out.println("Filter Capability Area(s) INIT as = " + filter.getCapabilityAreas());

        msg.append("Advanced Search Parameters = ");
        msg.append(
            "<div style=\"font-family: 'trebuchet ms', sans-serif;  font-size: 9px; font-style: italic; text-transform: lowercase; display: inline; \">");
        msg.append(filter.toFilterString());
        msg.append("</div><br />");
      }
    } else if (deleted.length == 0) {
      // came from projects list but nothing to do...later when table cells are editable, we may @TO
      // DO capture all edits/updates here
    } else {
      parameterDAO.deleteProject(deleted);
      int count = 0;
      for (int i = 0; i < deleted.length; i++) {
        count++;

        if (count == 1) {
          msg.append("Project(s) <strong><span style=\"background-color: #FFFF00\">");
        } else {
          msg.append(",&nbsp;<strong><span style=\"background-color: #FFFF00\">");
        }
        msg.append(
            StringEscapeUtils.escapeHtml(
                parameterDAO.getJustOneProject(deleted[i]).getProjectname()));
        msg.append("</span></strong>");
      }
      if (count > 0) msg.append(" D E L E T E D<BR />");
    }

    /////////////////////////////////////////////
    //  Draw the projects list table
    //
    out.println(getHeader());
    out.println(getMessageTable(msg));
    // System.out.println("AddProjectServlet.doPost drawing projects table " + filter.toString());

    if (StringUtils.isBlank(sortby)) {
      out.println(getProjectsListHTML());
    } else if (StringUtils.equalsIgnoreCase(sortby, "code")) {
      out.println(getProjectsListHTML("code", order));
    } else if (StringUtils.equalsIgnoreCase(sortby, "name")) {
      out.println(getProjectsListHTML("nametitle", order));
    } else if (StringUtils.equalsIgnoreCase(sortby, "description")) {
      out.println(getProjectsListHTML("description", order));
    } else if (StringUtils.equalsIgnoreCase(sortby, "status")) {
      out.println(getProjectsListHTML("status", order));
    } else {
      out.println(getProjectsListHTML());
    }

    out.println(getFooter());
    filter = new ProjectBean();
    // System.out.println("AddProjectServlet.doPost DONE");

  }
Esempio n. 10
0
 public void init(ServletConfig config) throws ServletException {
   super.init(config);
   System.out.println("[Servlet3.init]");
   context = config.getServletContext();
 }
Esempio n. 11
0
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    context = config.getServletContext();

    TextProcessor tp = new CaseFolder();

    try {
      wikipedia =
          new Wikipedia(
              context.getInitParameter("mysql_server"),
              context.getInitParameter("mysql_database"),
              context.getInitParameter("mysql_user"),
              context.getInitParameter("mysql_password"));
    } catch (Exception e) {
      throw new ServletException("Could not connect to wikipedia database.");
    }

    // Escaper escaper = new Escaper() ;

    definer = new Definer(this);
    comparer = new Comparer(this);
    searcher = new Searcher(this);

    try {
      wikifier = new Wikifier(this, tp);

    } catch (Exception e) {
      System.err.println("Could not initialize wikifier");
    }

    try {
      File dataDirectory = new File(context.getInitParameter("data_directory"));

      if (!dataDirectory.exists() || !dataDirectory.isDirectory()) {
        throw new Exception();
      }

      cachingThread = new CacherThread(dataDirectory, tp);
      cachingThread.start();
    } catch (Exception e) {
      throw new ServletException("Could not locate wikipedia data directory.");
    }

    try {
      TransformerFactory tf = TransformerFactory.newInstance();

      transformersByName = new HashMap<String, Transformer>();
      transformersByName.put(
          "help", buildTransformer("help", new File("/research/wikipediaminer/web/xsl"), tf));
      transformersByName.put(
          "loading", buildTransformer("loading", new File("/research/wikipediaminer/web/xsl"), tf));
      transformersByName.put(
          "search", buildTransformer("search", new File("/research/wikipediaminer/web/xsl"), tf));
      transformersByName.put(
          "compare", buildTransformer("compare", new File("/research/wikipediaminer/web/xsl"), tf));
      transformersByName.put(
          "wikify", buildTransformer("wikify", new File("/research/wikipediaminer/web/xsl"), tf));

      Transformer serializer = TransformerFactory.newInstance().newTransformer();
      serializer.setOutputProperty(OutputKeys.INDENT, "yes");
      serializer.setOutputProperty(OutputKeys.METHOD, "xml");
      serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3");
      transformersByName.put("serializer", serializer);

    } catch (Exception e) {
      throw new ServletException("Could not load xslt library.");
    }
  }
Esempio n. 12
0
 /** {@inheritDoc} */
 public String getParameter(String pName) {
   return config.getInitParameter(pName);
 }
Esempio n. 13
0
 /** {@inheritDoc} */
 public Enumeration getNames() {
   return config.getInitParameterNames();
 }
Esempio n. 14
0
 public void init(ServletConfig conf) {
   this.conf = conf;
   company = (String) conf.getInitParameter("company");
   location = (String) conf.getInitParameter("location");
 }
Esempio n. 15
0
 /**
  * (non-Javadoc)
  *
  * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
  */
 public void init(ServletConfig _servletConfig) throws ServletException {
   _delegate = new FacesServlet();
   _delegate.init(_servletConfig);
   _errorPage = _servletConfig.getInitParameter(INIT_PARAM_ERROR_PAGE);
 }
Esempio n. 16
0
package com.jspsmart.upload;
	// 初始化
	public void init(ServletConfig config) {
		savePath = config.getInitParameter("savePath");
		sc = config.getServletContext();
	}
Esempio n. 18
0
 public void init(ServletConfig config) throws ServletException {
   super.init(config);
   context = config.getServletContext();
 }