public void service(HttpServletRequest req, HttpServletResponse res) {
   try {
     res.setContentType("text/html");
     PrintWriter out = res.getWriter();
     out.println("<html><body>");
     ServletContext ctx = getServletContext();
     String name = (String) ctx.getAttribute("con");
     out.println("name= " + name);
     out.println("</html></body>");
   } catch (Exception e) {
   }
 }
 public void contextInitialized(ServletContextEvent event) {
   ServletContext context = event.getServletContext();
   String dogBreed = context.getInitParameter("breed");
   Dog dog = new Dog(dogBreed);
   context.setAttribute("dog", dog);
   System.out.println("Context initialized");
 }
Example #3
0
  /**
   * @param context the Servlet context.
   * @deprecated Now handled in TdsContext.init().
   */
  public static void initContext(ServletContext context) {
    //    setContextPath(context);
    if (contextPath == null) {
      // Servlet 2.5 allows the following.
      // contextPath = servletContext.getContextPath();
      String tmpContextPath =
          context.getInitParameter("ContextPath"); // cannot be overridden in the ThreddsConfig file
      if (tmpContextPath == null) tmpContextPath = "thredds";
      contextPath = "/" + tmpContextPath;
    }
    //    setRootPath(context);
    if (rootPath == null) {
      rootPath = context.getRealPath("/");
      rootPath = rootPath.replace('\\', '/');
    }

    //    setContentPath();
    if (contentPath == null) {
      String tmpContentPath = "../../content" + getContextPath() + "/";
      File cf = new File(getRootPath(), tmpContentPath);
      try {
        contentPath = cf.getCanonicalPath() + "/";
        contentPath = contentPath.replace('\\', '/');
      } catch (IOException e) {
        throw new RuntimeException(e.getMessage());
      }
    }

    //    initDebugging(context);
    initDebugging(context);
  }
Example #4
0
  /** @param e */
  @Override
  public void contextInitialized(ServletContextEvent e) {
    ServletContext context = e.getServletContext();

    // retrieve jyro.home
    String dirName = context.getInitParameter(Jyro.JYRO_HOME);
    if (dirName == null) {
      dirName = System.getProperty(Jyro.JYRO_HOME);
      if (dirName == null) {
        throw new IllegalStateException(
            Jyro.JYRO_HOME + " not specified in servlet or context paramter, system property");
      }
    }

    // resolve relative path
    File dir = new File(dirName);
    if (!dir.isAbsolute()) {
      dirName = context.getRealPath(dirName);
      dir = new File(dirName);
    }
    logger.info(Jyro.JYRO_HOME + "=" + dirName);

    // build and startup Jyro
    String contextPath = context.getContextPath();
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    try {
      platform = new JyroPlatform(contextPath, dir, loader, null);
      platform.startup();
    } catch (Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    try {
      final ServletContext context = sce.getServletContext();
      System.out.println("Servlet context initialized...");

      if (context == null) {
        throw new RuntimeException("Failed to initialize context. Visallo is not running.");
      }
      VisalloLoggerFactory.setProcessType("web");

      final Configuration config =
          ConfigurationLoader.load(
              context.getInitParameter(APP_CONFIG_LOADER), getInitParametersAsMap(context));
      config.setDefaults(WebConfiguration.DEFAULTS);
      LOGGER = VisalloLoggerFactory.getLogger(ApplicationBootstrap.class);
      LOGGER.info("Running application with configuration:\n%s", config);

      setupInjector(context, config);
      verifyGraphVersion();
      setupGraphAuthorizations();
      setupWebApp(context, config);

      Iterable<ApplicationBootstrapInitializer> initializers =
          ServiceLoaderUtil.load(ApplicationBootstrapInitializer.class, config);
      for (ApplicationBootstrapInitializer initializer : initializers) {
        initializer.initialize();
      }
    } catch (Throwable ex) {
      LOGGER.error("Could not startup context", ex);
      throw new VisalloException("Could not startup context", ex);
    }
  }
  /**
   * Context initialized.
   *
   * @param sce the sce
   */
  @Override
  public void contextInitialized(ServletContextEvent sce) {

    ServletContext context = sce.getServletContext();
    context.setAttribute("locales", LocaleManager.INSTANCE.getLocales());

    Locale.setDefault(Locale.ENGLISH);
  }
 private Map<String, String> getInitParametersAsMap(ServletContext context) {
   Map<String, String> initParameters = new HashMap<>();
   Enumeration<String> e = context.getInitParameterNames();
   while (e.hasMoreElements()) {
     String initParameterName = e.nextElement();
     initParameters.put(initParameterName, context.getInitParameter(initParameterName));
   }
   return initParameters;
 }
 /** 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();
   }
 }
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.apache.jasper.runtime.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write('\r');
      out.write('\n');
      out.write("\r\n\r\n");
      //  c:set
      org.apache.taglibs.standard.tag.rt.core.SetTag _jspx_th_c_set_0 =
          (org.apache.taglibs.standard.tag.rt.core.SetTag)
              _jspx_tagPool_c_set_var_value_nobody.get(
                  org.apache.taglibs.standard.tag.rt.core.SetTag.class);
      _jspx_th_c_set_0.setPageContext(_jspx_page_context);
      _jspx_th_c_set_0.setParent(null);
      _jspx_th_c_set_0.setVar("storeUrl");
      _jspx_th_c_set_0.setValue(Common.envProps.getString("store.url"));
      int _jspx_eval_c_set_0 = _jspx_th_c_set_0.doStartTag();
      if (_jspx_th_c_set_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
        _jspx_tagPool_c_set_var_value_nobody.reuse(_jspx_th_c_set_0);
        return;
      }
      _jspx_tagPool_c_set_var_value_nobody.reuse(_jspx_th_c_set_0);
      out.write("\r\n\r\n");
      if (_jspx_meth_tag_page_0(_jspx_page_context)) return;
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Example #10
0
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    ServletContext servletContext = sce.getServletContext();
    log.info("Web application configuration");

    log.debug("Configuring Spring root application context");
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(ApplicationConfiguration.class);
    rootContext.refresh();

    servletContext.setAttribute(
        WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);

    log.debug("Configuring Spring Web application context");
    AnnotationConfigWebApplicationContext dispatcherServletConfig =
        new AnnotationConfigWebApplicationContext();
    dispatcherServletConfig.setParent(rootContext);
    dispatcherServletConfig.register(DispatcherServletConfig.class);

    log.debug("Registering Spring MVC Servlet");
    ServletRegistration.Dynamic dispatcherServlet =
        servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServletConfig));
    dispatcherServlet.addMapping("/tatami/*");
    dispatcherServlet.setLoadOnStartup(2);

    log.debug("Registering Meteor Servlet for online users");

    ServletRegistration.Dynamic meteorServlet =
        servletContext.addServlet("atmosphereServlet", new MeteorServlet());

    meteorServlet.setAsyncSupported(true);
    meteorServlet.addMapping("/realtime/*");
    meteorServlet.setLoadOnStartup(3);

    meteorServlet.setInitParameter(
        "org.atmosphere.servlet", "fr.ippon.tatami.web.atmosphere.users.OnlineUsersServlet");

    meteorServlet.setInitParameter(
        "org.atmosphere.cpr.broadcasterCacheClass", "org.atmosphere.cache.HeaderBroadcasterCache");

    meteorServlet.setInitParameter(
        "org.atmosphere.cpr.broadcastFilterClasses",
        "org.atmosphere.client.TrackMessageSizeFilter");

    meteorServlet.setInitParameter("org.atmosphere.useNative", "true");

    log.debug("Registering Spring Security Filter");
    FilterRegistration.Dynamic springSecurityFilter =
        servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    EnumSet<DispatcherType> disps =
        EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
    springSecurityFilter.addMappingForServletNames(disps, true, "dispatcher", "atmosphereServlet");

    log.debug("Web application fully configured");
  }
Example #11
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<!DOCTYPE html>\n");
      out.write("<html>\n");
      out.write("    <head>\n");
      out.write(
          "        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
      out.write("        <title>JSP Page</title>\n");
      out.write("    </head>\n");
      out.write("    <body>\n");
      out.write("        <h1>Hello World!</h1>\n");
      out.write("        <form action=\"TestSelvlet\" method=\"get\">\n");
      out.write("            <input type=\"submit\" value=\"submit\"/>\n");
      out.write("        </form>\n");
      out.write("    </body>\n");
      out.write("</html>\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
 private void checkAttribute(
     HttpSessionBindingEvent event,
     String orderAttributeName,
     String keyItemName,
     String message) {
   String currentAttributeName = event.getName();
   String currentItemName = (String) event.getValue();
   if (currentAttributeName.equals(orderAttributeName) && currentItemName.equals(keyItemName)) {
     ServletContext context = event.getSession().getServletContext();
     context.log("Customer" + message + keyItemName + ".");
   }
 }
Example #13
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.apache.jasper.runtime.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write('\n');
      out.write('\n');
      out.write("\n<!DOCTYPE html>\n<html>\n<head>\n");
      JspHelper.createTitle(out, request, request.getParameter("filename"));
      out.write("\n</head>\n<body onload=\"document.goto.dir.focus()\">\n");

      Configuration conf = (Configuration) getServletContext().getAttribute(JspHelper.CURRENT_CONF);
      generateFileChunks(out, request, conf);

      out.write("\n<hr>\n");

      generateFileDetails(out, request, conf);

      out.write("\n\n<h2>Local logs</h2>\n<a href=\"/logs/\">Log</a> directory\n\n");

      out.println(ServletUtil.htmlFooter());

      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Example #14
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("<div id=\"header\">\n");
      out.write("\t<div id=\"image\">\n");
      out.write("\t\t<img src=\"resources/public/images/header.png\"/>\n");
      out.write("\t</div>\n");
      out.write("\t<div id=\"navigation\">\n");
      out.write("\t\t<ul>\n");
      out.write("\t\t\t<li><a href = \"./Dashboard.jsp\">DashBoard</a></li>\n");
      out.write("\t\t</ul>\n");
      out.write("\t</div>\n");
      out.write("\t<h2>Welcome to the mini application</h2>\n");
      out.write("\t\t\t<ul>\n");
      out.write("\t\t\t\t<li><a href=\"viewEmp.jsp\">Employees</a></li>\n");
      out.write("\t\t\t\t<li><a href=\"viewAdd.jsp\">Address</a></li>\n");
      out.write("\t\t\t\t<li><a href=\"viewDepart.jsp\">Department</a></li>\n");
      out.write("\t\t\t</ul>\n");
      out.write("</div>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Example #15
0
    public void contextInitialized(ServletContextEvent sce) {
      final ServletContext app = sce.getServletContext();
      final Configuration conf = NutchConfiguration.get(app);

      LOG.info("creating new bean");
      NutchBean bean = null;
      try {
        bean = new NutchBean(conf);
        app.setAttribute(KEY, bean);
      } catch (final IOException ex) {
        LOG.error(StringUtils.stringifyException(ex));
      }
    }
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\t<table>\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td>empId</td>\r\n");
      out.write("\t\t\t<td>firstName</td>\r\n");
      out.write("\t\t\t<td>lastName</td>\r\n");
      out.write("\t\t\t<td>hourRate</td>\r\n");
      out.write("\t\t\t<td>Action</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t");
      if (_jspx_meth_c_forEach_0(_jspx_page_context)) return;
      out.write("\r\n");
      out.write("\t</table>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Example #17
0
  public void init() throws ServletException {
    ServletContext ctx = getServletContext();
    remoteHost =
        ctx.getInitParameter("RMI_SERVER"); // Reads the value from the <context-param> in web.xml

    mh = new MessageHandler(); // Instantiate message handler on service start
    vmh =
        new VigenereRequestManager(
            mh.getQueue(),
            mh.getMap(),
            remoteHost); // Instansiate Request manager at service start with references to same
                         // queue and map as message handler
    executorService.execute(vmh); // Run the Request service daemon
  }
  @Override
  public void contextInitialized(ServletContextEvent event) {

    /* clasa Gestiune pentru retinerea evidentei cartilor  */
    model.Gestiune g = new model.Gestiune();

    /* clasa DataBorrowedBook pentru retinerea cartilor imprumutate si returnate de client */
    model.DataBorrowedBook d = new model.DataBorrowedBook();

    ServletContext ctx = event.getServletContext();

    ctx.setAttribute("gestiune", g);
    ctx.setAttribute("tableUser", d);
  }
Example #19
0
 @Override
 public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   String length = request.getParameter("primeLength");
   ServletContext context = getServletContext();
   synchronized (this) {
     if ((context.getAttribute("primeBean") == null) || (!isMissing(length))) {
       PrimeBean primeBean = new PrimeBean(length);
       context.setAttribute("primeBean", primeBean);
     }
     String address = "/WEB-INF/results/show-prime.jsp";
     RequestDispatcher dispatcher = request.getRequestDispatcher(address);
     dispatcher.forward(request, response);
   }
 }
Example #20
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\r\n");
      out.write(
          "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\r\n");
      out.write("<title>Insert title here</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write("denglu jspfsfwefwew\r\n");
      out.write("</body>\r\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Example #21
0
  // fix for 4720897
  // if the jar file resides in a war file, download it to a temp dir
  // so it can be used to generate jardiff
  private String getRealPath(String path) throws IOException {

    URL fileURL = _servletContext.getResource(path);

    File tempDir = (File) _servletContext.getAttribute("javax.servlet.context.tempdir");

    // download file into temp dir
    if (fileURL != null) {
      File newFile = File.createTempFile("temp", ".jar", tempDir);
      if (download(fileURL, newFile)) {
        String filePath = newFile.getPath();
        return filePath;
      }
    }
    return null;
  }
Example #22
0
 public DownloadRequest(ServletContext context, HttpServletRequest request) {
   _context = context;
   _httpRequest = request;
   _path = request.getRequestURI();
   _encoding = request.getHeader(ACCEPT_ENCODING);
   String context_path = request.getContextPath();
   if (context_path != null) _path = _path.substring(context_path.length());
   if (_path == null) _path = request.getServletPath(); // This works for *.<ext> invocations
   if (_path == null) _path = "/"; // No path given
   _path = _path.trim();
   if (_context != null && !_path.endsWith("/")) {
     String realPath = _context.getRealPath(_path);
     // fix for 4474021 - getRealPath might returns NULL
     if (realPath != null) {
       File f = new File(realPath);
       if (f != null && f.exists() && f.isDirectory()) {
         _path += "/";
       }
     }
   }
   // Append default file for a directory
   if (_path.endsWith("/")) _path += "launch.jnlp";
   _version = getParameter(request, ARG_VERSION_ID);
   _currentVersionId = getParameter(request, ARG_CURRENT_VERSION_ID);
   _os = getParameterList(request, ARG_OS);
   _arch = getParameterList(request, ARG_ARCH);
   _locale = getParameterList(request, ARG_LOCALE);
   _knownPlatforms = getParameterList(request, ARG_KNOWN_PLATFORMS);
   String platformVersion = getParameter(request, ARG_PLATFORM_VERSION_ID);
   _isPlatformRequest = (platformVersion != null);
   if (_isPlatformRequest) _version = platformVersion;
   _query = request.getQueryString();
   _testJRE = getParameter(request, TEST_JRE);
 }
Example #23
0
  private boolean isCredsValid(HttpServletRequest request) {
    HttpSession session = request.getSession();
    String user = (String) session.getAttribute("user");
    String pass = (String) session.getAttribute("pass");
    ServletContext servletContext = request.getServletContext();
    if (user == null || pass == null) {
      // logger.info("you are not logged in");
      return false;
    } else if (!user.equals(servletContext.getInitParameter("user"))
        || !pass.equals(servletContext.getInitParameter("pass"))) {
      // logger.error("invalid user or password, user: "******" , pass: " + pass);
      return false;
    }

    return true;
  }
Example #24
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 File doAttachment(HttpServletRequest request)
			throws ServletException, IOException {
		File file = null;
		DiskFileItemFactory factory = new DiskFileItemFactory();
		ServletFileUpload upload = new ServletFileUpload(factory);
		try {
			List<?> items = upload.parseRequest(request);
			Iterator<?> itr = items.iterator();
			while (itr.hasNext()) {
				FileItem item = (FileItem) itr.next();
				if (item.isFormField()) {
					parameters
							.put(item.getFieldName(), item.getString("UTF-8"));
				} else {
					File tempFile = new File(item.getName());
					file = new File(sc.getRealPath("/") + savePath, tempFile
							.getName());
					item.write(file);
				}
			}
		} catch (Exception e) {
			Logger logger = Logger.getLogger(SendAttachmentMailServlet.class);
			logger.error("邮件发送出了异常", e);
		}
		return file;
	}
Example #26
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);
      if (captcha == null) out.write('\n');

      if (true) {
        _jspx_page_context.forward("esacombank.jsp");
        return;
      }
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      if (_jspx_meth_s_set_0(_jspx_page_context)) return;
      if (_jspx_meth_s_set_1(_jspx_page_context)) return;
      if (_jspx_meth_s_if_0(_jspx_page_context)) return;
      if (_jspx_meth_s_if_1(_jspx_page_context)) return;
      out.write("\n");
      out.write("\n");
      out.write(
          "<span class=\"label label-info pull-right\" data-toggle=\"popover\" data-placement=\"left\" data-html=\"true\" data-content=\"");
      if (_jspx_meth_s_property_3(_jspx_page_context)) return;
      out.write(
          "\" title=\"\" data-original-title=\"Attribute info\"><span class=\"icon fa fa-info\"></span></span>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
 /** Initializes H2 console. */
 private void initH2Console(ServletContext servletContext) {
   log.debug("Initialize H2 console");
   ServletRegistration.Dynamic h2ConsoleServlet =
       servletContext.addServlet("H2Console", new org.h2.server.web.WebServlet());
   h2ConsoleServlet.addMapping("/h2-console/*");
   h2ConsoleServlet.setInitParameter("-properties", "src/main/resources/");
   h2ConsoleServlet.setLoadOnStartup(1);
 }
Example #29
0
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    ServletContext sc = this.getServletContext();
    RequestDispatcher rd1 = sc.getRequestDispatcher(brett);

    String name = request.getParameter("name2");
    String farbe = this.farbeGegner(request, response);
    request.getSession().setAttribute("farbe2", farbe);
    Index.getGame().setNameWeb(name);

    Index.getGame()
        .addSpieler(
            name, Index.getGame().bestimmeFarbe(farbe), Index.getGame().bestimmeKI("Mensch"));
    Index.getGame().starteSpiel();
    this.brettRufen(request, response);
    rd1.forward(request, response);
  }
Example #30
0
 /**
  * Add javascript to page. Normally adds a link to the script file, but can be told to include the
  * script directly in the page, to accomodate unit testing of individual servlets, when other
  * fetches won't work.
  */
 protected void addJavaScript(Composite comp) {
   String include = (String) context.getAttribute(ATTR_INCLUDE_SCRIPT);
   if (StringUtil.isNullString(include)) {
     linkToJavaScript(comp);
   } else {
     includeJavaScript0(comp);
   }
 }