public int doEndTag() throws JspException {
    if ((jspFile.indexOf("..") >= 0)
        || (jspFile.toUpperCase().indexOf("/WEB-INF/") != 0)
        || (jspFile.toUpperCase().indexOf("/META-INF/") != 0))
      throw new JspTagException("Invalid JSP file " + jspFile);

    InputStream in = pageContext.getServletContext().getResourceAsStream(jspFile);

    if (in == null) throw new JspTagException("Unable to find JSP file: " + jspFile);

    InputStreamReader reader = new InputStreamReader(in);
    JspWriter out = pageContext.getOut();

    try {
      out.println("<body>");
      out.println("<pre>");
      for (int ch = in.read(); ch != -1; ch = in.read())
        if (ch == '<') out.print("&lt;");
        else out.print((char) ch);
      out.println("</pre>");
      out.println("</body>");
    } catch (IOException ex) {
      throw new JspTagException("IOException: " + ex.toString());
    }
    return super.doEndTag();
  }
 /**
  * @return
  * @throws JspException 作者:孙树林 创建日期:2010-12-29
  */
 @Override
 public int doStartTag() throws JspException {
   JspWriter writer = pageContext.getOut();
   try {
     ValueStack stack = TagUtils.getStack(pageContext);
     Object obj = stack.findValue("ex");
     GeneralException exception = (GeneralException) obj;
     writer.print("错误信息:<br>");
     writer.print(exception.getMessage() + "<br>");
     StackTraceElement[] elements = exception.getStackTrace();
     writer.print("详细内容:<br>");
     for (StackTraceElement element : elements) {
       writer.println(
           element.getClassName()
               + "."
               + element.getMethodName()
               + "("
               + element.getFileName()
               + ": "
               + element.getLineNumber()
               + ")<br>");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return EVAL_PAGE;
 }
Example #3
0
  /** {@inheritDoc} */
  @Override
  public final int doWikiStartTag() throws IOException {
    WikiEngine engine = m_wikiContext.getEngine();
    JspWriter out = pageContext.getOut();
    ResourceBundle rb = m_wikiContext.getBundle(InternationalizationManager.CORE_BUNDLE);

    if (engine.getRSSGenerator() != null && engine.getRSSGenerator().isEnabled()) {
      if (RSSGenerator.MODE_FULL.equals(m_mode)) {
        String rssURL = engine.getGlobalRSSURL();

        if (rssURL != null) {
          out.print("<a class=\"feed\" href=\"" + rssURL + "\">&nbsp;</a>");
        }
      } else {
        String page = m_pageName != null ? m_pageName : m_wikiContext.getPage().getName();

        String params = "page=" + page + "&mode=" + m_mode;
        out.print("<a href='" + m_wikiContext.getURL(WikiContext.NONE, "rss.jsp", params));
        out.print("' class='feed'");
        out.print(" title='" + MessageFormat.format(rb.getString("rss.title"), page) + "'>");
        out.print("&nbsp;</a> ");
      }
    }

    return SKIP_BODY;
  }
Example #4
0
 public int doStartTag() throws JspTagException {
   javax.servlet.jsp.tagext.Tag parent = getParent();
   ServletRequest request = pageContext.getRequest();
   JspWriter out = pageContext.getOut();
   if (name == null && param == null)
     throw new JspTagException("ListElemTag >> name or param is required");
   if (value == null && param == null)
     throw new JspTagException("ListElemTag >> value or param is required");
   if (name == null) name = param;
   if (value == null && param != null) value = request.getAttribute(param);
   if (value == null) throw new JspTagException("ListElemTag >> value is null");
   if (value instanceof List) iter = ((List) value).iterator();
   else if (value instanceof Iterator) iter = (Iterator) value;
   else throw new JspTagException("value must be List or Iterator");
   try {
     out.print("<list name='" + name + "'>\n");
     if (iter.hasNext()) {
       cnt++;
       data = iter.next();
       out.print("<entry no='" + cnt++ + "'>");
       return 1;
     }
   } catch (IOException e) {
     throw new JspTagException("ListElemTag >> " + e.getMessage());
   }
   return 0;
 }
  @Override
  public int doStartTag() throws JspException {
    String language = (String) pageContext.getSession().getAttribute("param.language");

    Locale locale;
    if (language != null) {
      locale = new Locale(language, language.toUpperCase());
    } else {
      locale = pageContext.getRequest().getLocale();
    }

    ResourceBundle resource =
        ResourceBundle.getBundle("by.gstu.Testing.resource.pagestext", locale);
    JspWriter writer = pageContext.getOut();
    try {
      try {
        writer.print(new String(resource.getString(key).getBytes("ISO-8859-1"), "UTF-8"));
      } catch (MissingResourceException ex) {
        logger.debug(ex);
        writer.print(resource.getString("resource.not.found"));
      }
    } catch (IOException ex) {

    }
    return SKIP_BODY;
  }
Example #6
0
 public void addTableRow(JspWriter out, String[] columns) throws IOException {
   out.print("<tr>");
   for (String col : columns) {
     out.print("<td>" + col + "</td>\n");
   }
   out.print("</tr>");
 }
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n");
      out.write("\n\n");

      // Get the current user's ac
      WTAccountCredentials ac = WTAccountCredentials.current();
      SecureInfoManagerImpl sim = new SecureInfoManagerImpl();

      // Setup for permission checking
      boolean editInterfaces = false;
      if (sim.canEditEntity(ProtectedResourceConstants.PR_INTERFACES, ac)) editInterfaces = true;
      pageContext.setAttribute("editInterfaces", new Boolean(editInterfaces));

      out.write("  \n");

      String hostIP = null;
      try {
        hostIP = InetAddress.getLocalHost().getHostAddress();
        //    out.print(hostIP);

      } catch (UnknownHostException ex) {
        throw new Exception("Could not determine the local host address", ex);
      }

      out.write("\n\nvar javaScriptVar=\"");
      out.print(hostIP);
      out.write("\";\nvar javaScriptVar2=\"");
      out.print(editInterfaces);
      out.write("\";\n");
    } catch (Throwable t) {
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0) out.clearBuffer();
      if (pageContext != null) pageContext.handlePageException(t);
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    }
  }
  @Override
  public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();

    if (attach == null || StringUtils.isBlank(attach.getSavedName())) {
      out.print("");
    } else {
      out.print(prefix + attach.getSavedDirectory() + "/" + attach.getSavedName());
    }
  }
  public void
  _jspService(javax.servlet.http.HttpServletRequest request,
              javax.servlet.http.HttpServletResponse response)
    throws java.io.IOException, javax.servlet.ServletException
  {
    javax.servlet.http.HttpSession session = request.getSession(true);
    com.caucho.server.webapp.WebApp _jsp_application = _caucho_getApplication();
    javax.servlet.ServletContext application = _jsp_application;
    com.caucho.jsp.PageContextImpl pageContext = _jsp_application.getJspApplicationContext().allocatePageContext(this, _jsp_application, request, response, null, session, 8192, true, false);
    javax.servlet.jsp.PageContext _jsp_parentContext = pageContext;
    javax.servlet.jsp.JspWriter out = pageContext.getOut();
    final javax.el.ELContext _jsp_env = pageContext.getELContext();
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.Servlet page = this;
    response.setContentType("text/html;charset=EUC-KR");
    request.setCharacterEncoding("EUC-KR");
    try {
      out.write(_jsp_string0, 0, _jsp_string0.length);
      
	String filename = request.getParameter("filename");
	String downname = request.getParameter("downname");
	FormDataDownload formData = new FormDataDownload(response, new File(filename), null, null);
	try
	{
		formData.download();
	}catch(FileNotFoundException e)
	{
		
      out.write(_jsp_string1, 0, _jsp_string1.length);
      out.print(( e ));
      out.write(_jsp_string2, 0, _jsp_string2.length);
      
		return;
	}catch(IOException e)
	{
		
      out.write(_jsp_string3, 0, _jsp_string3.length);
      out.print(( e ));
      out.write(_jsp_string4, 0, _jsp_string4.length);
      
		return;
	}catch(Exception e)
	{
		System.out.println("Exception Error~~" + e);
	}

      out.write('\n');
    } catch (java.lang.Throwable _jsp_e) {
      pageContext.handlePageException(_jsp_e);
    } finally {
      _jsp_application.getJspApplicationContext().freePageContext(pageContext);
    }
  }
Example #10
0
 @Override
 protected void doEdit(JspWriter out) throws IOException {
   out.println("<select name=\"userRole\">");
   for (UserRoles role : UserRoles.values()) {
     out.print("<option ");
     if (userRole != null) {
       if (role.equals(userRole)) {
         out.print(" selected ");
       }
     }
     out.print(" value=\"" + role.name() + "\">" + role.name() + "</option>");
   }
   out.println("</select>");
 }
Example #11
0
  /**
   * Default processing of the start tag returning EVAL_BODY_BUFFERED.
   *
   * @return EVAL_BODY_BUFFERED
   * @throws JspException if an error occurred while processing this tag
   * @see BodyTag#doStartTag
   */
  @Override
  public int doStartTag() throws JspException {
    try {
      JspWriter out = this.pageContext.getOut();
      this.sys = this.getSys() != null ? this.getSys().trim() : "";
      this.app = this.getApp() != null ? this.getApp().trim() : "";
      this.title = this.getTitle() != null ? this.getTitle().trim() : "";
      this.accessKey = this.getAccessKey() != null ? this.getAccessKey().trim() : "";

      TagElement tagElem = new TagElement(ElementType.LI);
      tagElem.addClass(this.getTagType() + " sub_nav " + TAG);
      tagElem.attr(SYS, this.sys);
      tagElem.attr(APP, this.app);
      tagElem.attr(ACCESSKEY, this.accessKey);
      tagElem.html(
          "<a class='title'>"
              + this.title
              + "</a><a class='_title'>"
              + this.getShortName()
              + "</a>");
      out.print(tagElem.toString());
    } catch (IOException e) {
      LOG.error(EXCEPTION + e.getMessage(), e);
    }
    return (SKIP_BODY);
  }
Example #12
0
 public int doAfterBody() throws JspTagException {
   javax.servlet.jsp.tagext.Tag parent = getParent();
   ServletRequest request = pageContext.getRequest();
   JspWriter out = pageContext.getOut();
   try {
     out.print("</entry>\n");
     if (iter.hasNext()) {
       data = iter.next();
       out.print("<entry no='" + cnt++ + "'>");
       return 2;
     }
   } catch (IOException e) {
     throw new JspTagException("ListElemTag >> " + e.getMessage());
   }
   return 6;
 }
Example #13
0
  private void writeAsSpanLabel() throws JspException {
    try {
      getAttributes().remove("radio");
      if (isChecked()) {
        JspWriter writer = getPageContext().getOut();
        if (getId() != null) {
          set("id", getId());
        }
        set("class", !Str.isEmpty(readOnlyClass) ? readOnlyClass : DEFAULT_READONLY_CLASS);

        writeOpenTag(getPageContext().getOut(), "span");
        writer.print(checkedLabel);
        writeCloseTag(getPageContext().getOut(), "span");
      }
    } catch (IOException ioe) {
      JspException jspe =
          new JspException(
              MessageFormat.format(
                  "IOException encountered while writing value [{0}]  to the JspWriter.",
                  checkedLabel),
              ioe);
      LOG.warn(jspe);
      throw jspe;
    } finally {
      if (getId() != null) {
        getAttributes().remove("id");
      }
      getAttributes().remove("class");
    }
  }
Example #14
0
 public static void createTitle(JspWriter out, HttpServletRequest req, String file)
     throws IOException {
   if (file == null) file = "";
   int start = Math.max(0, file.length() - 100);
   if (start != 0) file = "..." + file.substring(start, file.length());
   out.print("<title>HDFS:" + file + "</title>");
 }
  public int doEndTag() throws JspException {
    TreeControl treeControl = getTreeControl();
    JspWriter out = pageContext.getOut();

    try {
      out.print("<table " + style + ">");
      out.println("<tr>");
      out.println("<th align='center'>机构名称</th>");
      out.println("<th align='center'>机构编号</th>");

      if (!para1.equals("-1")) {
        out.println("<th align='center'>报名人数</th>");
      } else {
        out.println("<th align='center'>报名表数</th>");
      }

      out.println("</tr>");

      int level = 0;
      TreeControlNode node = treeControl.getRoot();
      render(out, node, level, treeControl.getWidth(), true);
      out.println("</table>");
    } catch (IOException e) {
      throw new JspException(e);
    }

    return (EVAL_PAGE);
  }
Example #16
0
 @Override
 protected void doView(JspWriter out) throws IOException {
   if (userRole != null) {
     out.println("<input type=\"hidden\" name=\"userRole\" value=\"" + userRole + "\"/>");
     out.print(userRole);
   }
 }
Example #17
0
  @Override
  public int doEndTag() throws JspException {
    HttpSession httpSession = this.pageContext.getSession();
    Member loginMember = (Member) httpSession.getAttribute("ss_member");

    if (loginMember != null) userId = loginMember.getUserId();

    MyMenuInfo myMenuInfo = new MyMenuInfo();
    myMenuInfo.setUserId(userId);

    elementList = elementsService.getMyMenuInfoList(myMenuInfo);

    if (elementList.size() < 1) return EVAL_PAGE;

    StringBuffer htmlBuf = new StringBuffer();
    this.genMyMenuHtml(htmlBuf);

    // System.out.println(htmlBuf.toString());
    JspWriter w = pageContext.getOut();
    try {
      w.print(htmlBuf.toString());
    } catch (IOException e) {
      // TODO Auto-generated catch block
      throw new JspException(e.toString(), e);
    }
    return super.doEndTag();
  }
 /**
  * Test method for {@link org.apache.tiles.request.jsp.JspPrintWriterAdapter#print(double)}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testPrintDouble() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   writer.print(1d);
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   adapter.print(1d);
   verify(writer);
 }
 /**
  * Test method for {@link
  * org.apache.tiles.request.jsp.JspPrintWriterAdapter#print(java.lang.String)}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testPrintString() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   writer.print("this is a string");
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   adapter.print("this is a string");
   verify(writer);
 }
Example #20
0
 private int writerBody(String bodyStr) throws JspException {
   JspWriter jspOut = pageContext.getOut();
   try {
     jspOut.print(bodyStr);
   } catch (IOException e) {
     throw new JspException(e);
   }
   return super.doEndTag();
 }
Example #21
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    Throwable exception = org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);
    if (exception != null) {
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    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;

      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("\r\n");
      out.write("<title>Error Page</title>\r\n");
      out.write("</head>\r\n");
      out.write("\r\n");
      out.write("<body bgcolor=\"blue\">\r\n");
      out.write("\t<font size=\"16\" color=\"white\">Your page generated an error:\"<br />\r\n");
      out.write("\t\tException:<br /></font>\r\n");
      out.write("\t");
      out.print(exception.toString());
      out.write("\r\n");
      out.write("\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)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else log(t.getMessage(), t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Example #22
0
 public int doEndTag() {
   try {
     JspWriter out = pageContext.getOut();
     out.print("</SPAN></TABLE>");
   } catch (IOException ioe) {
     System.out.println("Error in HeadingTag: " + ioe);
   }
   return (EVAL_PAGE); // Continue with rest of JSP page
 }
  @Override
  public void doTag() throws JspException, IOException {

    JspWriter out = getJspContext().getOut();
    StringWriter stringWriter = new StringWriter();
    getJspBody().invoke(stringWriter);
    String highlightedValue = doHighlight(stringWriter.toString());
    out.print(highlightedValue);
  }
Example #24
0
 /**
  * Prints the.
  *
  * @param displayValue the display value
  * @param out the out
  * @throws JspException the jsp exception
  */
 private void print(String displayValue, JspWriter out) throws JspException {
   try {
     if (maxLength != -1 && displayValue.length() > maxLength) {
       String newValue;
       if (ellipsisRight) {
         newValue = displayValue.substring(0, maxLength - 3) + "...";
       } else {
         newValue = "..." + displayValue.substring(displayValue.length() - maxLength + 3);
       }
       String title = StringEscapeUtils.escapeHtml(displayValue);
       out.print("<span title=\"" + title + "\">" + newValue + "</span>");
     } else {
       out.print(displayValue);
     }
   } catch (IOException e) {
     throw new JspException(e);
   }
 }
 /**
  * Test method for {@link org.apache.tiles.request.jsp.JspPrintWriterAdapter#print(char[])}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testPrintCharArray() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   String result = "this is a test";
   writer.print(aryEq(result.toCharArray()));
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   adapter.print(result.toCharArray());
   verify(writer);
 }
 /**
  * Test method for {@link
  * org.apache.tiles.request.jsp.JspPrintWriterAdapter#print(java.lang.Object)}.
  *
  * @throws IOException If something goes wrong.
  */
 public void testPrintObject() throws IOException {
   JspWriter writer = createMock(JspWriter.class);
   Object obj = createMock(Object.class);
   writer.print(obj);
   JspPrintWriterAdapter adapter = new JspPrintWriterAdapter(writer);
   replay(writer);
   adapter.print(obj);
   verify(writer);
 }
  private void printFailures(
      JspWriter out, JobTracker tracker, JobID jobId, String kind, String cause)
      throws IOException {
    JobInProgress job = (JobInProgress) tracker.getJob(jobId);
    if (job == null) {
      out.print("<b>Job " + jobId + " not found.</b><br>\n");
      return;
    }

    boolean includeMap = false;
    boolean includeReduce = false;
    if (kind == null) {
      includeMap = true;
      includeReduce = true;
    } else if ("map".equals(kind)) {
      includeMap = true;
    } else if ("reduce".equals(kind)) {
      includeReduce = true;
    } else if ("all".equals(kind)) {
      includeMap = true;
      includeReduce = true;
    } else {
      out.print("<b>Kind " + kind + " not supported.</b><br>\n");
      return;
    }

    TaskStatus.State state = null;
    try {
      if (cause != null) {
        state = TaskStatus.State.valueOf(cause.toUpperCase());
        if (state != TaskStatus.State.FAILED && state != TaskStatus.State.KILLED) {
          out.print("<b>Cause '" + cause + "' is not an 'unsuccessful' state.</b><br>\n");
          return;
        }
      }
    } catch (IllegalArgumentException e) {
      out.print("<b>Cause '" + cause + "' not supported.</b><br>\n");
      return;
    }

    out.print("<table border=2 cellpadding=\"5\" cellspacing=\"2\">");
    out.print(
        "<tr><th>Attempt</th><th>Task</th><th>Machine</th><th>State</th>"
            + "<th>Error</th><th>Logs</th></tr>\n");
    if (includeMap) {
      TaskInProgress[] tips = job.getTasks(TaskType.MAP);
      for (int i = 0; i < tips.length; ++i) {
        printFailedAttempts(out, tracker, jobId, tips[i], state);
      }
    }
    if (includeReduce) {
      TaskInProgress[] tips = job.getTasks(TaskType.REDUCE);
      for (int i = 0; i < tips.length; ++i) {
        printFailedAttempts(out, tracker, jobId, tips[i], state);
      }
    }
    out.print("</table>\n");
  }
Example #28
0
 public int doAfterBody() throws JspException {
   try {
     JspWriter jspWrite = bodyContent.getEnclosingWriter();
     String convertString = bodyContent.getString();
     jspWrite.print(convertString.replaceAll("\r\n|\n", "<br />\n"));
   } catch (IOException e) {
     throw new JspException(e.getMessage());
   }
   return SKIP_BODY;
 }
Example #29
0
 public int doEndTag() throws JspTagException {
   try {
     JspWriter out = this.pageContext.getOut();
     out.print(end().toString());
     out.flush();
   } catch (IOException e) {
     e.printStackTrace();
   }
   return EVAL_PAGE;
 }
Example #30
0
 public int doEndTag() throws JspException {
   JspWriter writer = pageContext.getOut();
   try {
     writer.print(WebletUtils.getResource(weblet, pathInfo));
   } catch (IOException e) {
     e.printStackTrace();
     throw new JspException(e);
   }
   return super.doEndTag();
 }