Ejemplo n.º 1
0
  @SuppressWarnings("unchecked")
  private void handleAction(
      RenderVelocityAction action, String cmd, Vector[] args, HttpServletRequest request) {
    if (action != null) {
      // add parameter from path
      for (int p = 0; p < args[0].size(); p++) {
        action.putParam((String) args[0].get(p), (String) args[1].get(p));
      }

      VelocityContext c = new VelocityContext();
      try {
        c.put("action", action);
        c.put("encoding", action.encoding);
        c.put("cmd", cmd);

        // c.put("au", action.user);

        c.put("reqaddress", request.getRemoteAddr());
        c.put("scheme", request.getScheme());
        c.put("querystring", request.getQueryString());
        if (c.get("querystring") == null) {
          c.put("querystring", "");
        }

        String requesturl = request.getRequestURL().toString();

        // c.put("mid", ma.user.mandantid);
        c.put("request", request);
        c.put("requesturl", requesturl);
        c.put("server", request.getServerName());
        c.put("port", request.getServerPort());

        String ref = request.getHeader("Referer");
        if (ref == null) {
          ref = "#";
        }
        c.put("referer", ref);

        // process and render template
        action.process(c);

      } catch (Exception ex) {
        ex.printStackTrace();
        //	        		action.makeErrorOutput("Internal Error", null, c);
      }
    }
  }