javax.servlet.jsp.JspTagException Java Examples

The following examples show how to use javax.servlet.jsp.JspTagException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TopicMapReferencesTag.java    From ontopia with Apache License 2.0 6 votes vote down vote up
/**
 * Process the start tag for this instance.
 */
@Override
public int doStartTag() throws JspTagException {
  // retrieve parent tag which accepts the produced collection by this tag 
  ValueAcceptingTagIF acceptingTag = (ValueAcceptingTagIF)
    findAncestorWithClass(this, ValueAcceptingTagIF.class);

  // try to retrieve root ContextTag
  ContextTag contextTag = FrameworkUtils.getContextTag(pageContext);

  // get collection of TM Reference entries from Configuration
  Collection refs =
    contextTag.getNavigatorApplication().getTopicMapRepository().getReferences();
  
  // kick it up to the accepting tag
  acceptingTag.accept( refs );

  // ignore body, because this is an empty tag
  return SKIP_BODY;
}
 
Example #2
Source File: ValuesTag.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public int doEndTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {
        if (!"-1".equals(objectValue)) {
            out.print(objectValue);
        } else if (!"-1".equals(stringValue)) {
            out.print(stringValue);
        } else if (longValue != -1) {
            out.print(longValue);
        } else if (doubleValue != -1) {
            out.print(doubleValue);
        } else {
            out.print("-1");
        }
    } catch (IOException ex) {
        throw new JspTagException("IOException: " + ex.toString(), ex);
    }
    return super.doEndTag();
}
 
Example #3
Source File: SectionTitle.java    From unitime with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspException {
	if (getParent()!=null && getParent() instanceof SectionHeader) {
		((SectionHeader)getParent()).setTitle(getBodyContent().getString());
	} else {
		try {
			String body = (getBodyContent()==null?null:getBodyContent().getString());
			if (body==null || body.trim().length()==0) {
				pageContext.getOut().println("<DIV class='WelcomeRowHeadBlank'>&nbsp;</DIV>");
			} else {
				pageContext.getOut().println("<DIV class='WelcomeRowHead'>");
				pageContext.getOut().println(body);
				pageContext.getOut().println("</DIV>");
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new JspTagException(e.getMessage());
		}
	}
	return EVAL_PAGE;
}
 
Example #4
Source File: ReifierTag.java    From ontopia with Apache License 2.0 6 votes vote down vote up
@Override
public Collection process(Collection tmObjects) throws JspTagException {
  // Find all reifying topics of all topic map objects in collection
  if (tmObjects == null || tmObjects.isEmpty())
    return Collections.EMPTY_SET;
  else {
    ArrayList reifyingTopics = new ArrayList();
    Iterator iter = tmObjects.iterator();
    TopicIF reifyingTopic;
    // Loop over the topic map objects
    while (iter.hasNext()) {
      // Get the topic that reifies the given topic map object
      reifyingTopic = ((ReifiableIF)iter.next()).getReifier();
      // If a topic was found add it to the result list.
      if (reifyingTopic != null)
        reifyingTopics.add(reifyingTopic);    
    }
    // Return all reifiying topics found.
    return reifyingTopics;
  }
}
 
Example #5
Source File: SearchByTag.java    From Online-Library-System with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 为搜书功能中添加下拉框
 */
public void doTag() throws JspException, IOException {
	try {
		JspWriter out = jspContext.getOut();
		String outPrint = "";
		String[] color = { "Book Name", "Author", "Publisher", "ISBN" };
		outPrint += "<select id=\"input\" name=\"searchBy\"> ";
		for (int i = 0; i < color.length; i++) {
			outPrint += "<option>";
			outPrint += color[i];
			outPrint += "</option>";
		}
		outPrint += "</select>";
		out.print(outPrint);
	} catch (java.io.IOException e) {
		throw new JspTagException(e.getMessage());
	}
}
 
Example #6
Source File: OtherwiseTag.java    From ontopia with Apache License 2.0 6 votes vote down vote up
/**
 * Process the start tag for this instance.
 */
@Override
public int doStartTag() throws JspTagException {
  parentChooser = (ChooseTag) findAncestorWithClass(this, ChooseTag.class);
  if (parentChooser == null)
    throw new JspTagException(
            "tolog:otherwise tag is not inside tolog:choose tag.");

  ContextTag contextTag = FrameworkUtils.getContextTag(pageContext);
  
  if (contextTag == null)
    throw new JspTagException("<tolog:otherwise> must be nested directly or"
            + " indirectly within a <tolog:context> tag, but no"
            + " <tolog:context> tag was found.");
  
  contextTag.getContextManager().pushScope();
  
  // If a matching when was already found within the parentChooser
  if (parentChooser.foundMatchingWhen())
    // No more WhenTags need to be executed (tested in each WhenTag).
    return SKIP_BODY;
  return EVAL_BODY_BUFFERED;
}
 
Example #7
Source File: UrlTag.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
public int doEndTag() throws JspException {

        // Rewrite and encode the url.
        String result = formatUrl();

        // Store or print the output
        if (var != null)
            pageContext.setAttribute(var, result, PageContext.PAGE_SCOPE);
        else {
            try {
                pageContext.getOut().print(result);
            } catch (IOException x) {
                throw new JspTagException(x);
            }
        }
        return EVAL_PAGE;
    }
 
Example #8
Source File: UrlTag.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
public int doEndTag() throws JspException {

        // Rewrite and encode the url.
        String result = formatUrl();

        // Store or print the output
        if (var != null)
            pageContext.setAttribute(var, result, PageContext.PAGE_SCOPE);
        else {
            try {
                pageContext.getOut().print(result);
            } catch (IOException x) {
                throw new JspTagException(x);
            }
        }
        return EVAL_PAGE;
    }
 
Example #9
Source File: PermissionTag.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * permission control
 */
@Override
public int doStartTag() throws JspTagException {
	ComAdmin aAdmin = AgnUtils.getAdmin(pageContext);

	if (aAdmin == null) {
		throw new JspTagException("PermissionDenied$" + permissionToken);
	} else {
		boolean permissionGranted = false;
		try {
			permissionGranted = aAdmin.permissionAllowed(Permission.getPermissionsByToken(permissionToken));
		} catch (Exception e) {
			releaseException(e, permissionToken);
		}
		if (!permissionGranted) {
			throw new JspTagException("PermissionDenied$" + permissionToken);
		}

		return SKIP_BODY;
	}
}
 
Example #10
Source File: ValuesTag.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public int doEndTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {
        if (!"-1".equals(objectValue)) {
            out.print(objectValue);
        } else if (!"-1".equals(stringValue)) {
            out.print(stringValue);
        } else if (longValue != -1) {
            out.print(longValue);
        } else if (doubleValue != -1) {
            out.print(doubleValue);
        } else {
            out.print("-1");
        }
    } catch (IOException ex) {
        throw new JspTagException("IOException: " + ex.toString(), ex);
    }
    return super.doEndTag();
}
 
Example #11
Source File: AttributeTag.java    From ontopia with Apache License 2.0 6 votes vote down vote up
/**
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {
  ElementTag elementTag = (ElementTag)
    findAncestorWithClass(this, ElementTag.class);

  if (elementTag != null) {
    // get body content
    BodyContent body = getBodyContent();
    if (body != null) {
      String content = body.getString();
      // add this attribute to parent element tag 
      elementTag.addAttribute(attrName, content);
      body.clearBody();
    } else {
      log.warn("AttributeTag: body content is null!");
    }
  } else {
    log.warn("AttributeTag: no parent element tag found!");
  }
  
  // only evaluate body once
  return SKIP_BODY;
}
 
Example #12
Source File: BookLocationTag.java    From Online-Library-System with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 为添加书本中的location添加下拉框
 */
public void doTag() throws JspException, IOException {
	try {
		JspWriter out = jspContext.getOut();
		String outPrint = "";
		String[] color = { "四层-科技图书阅览区", "四层-科技图书典藏区", "三层-社科类图书阅览区", "三层-社科类图书典藏区", "二层-杂志期刊" };
		outPrint += "<select name='Location' size='1' class=\"form-control\"> ";
		for (int i = 0; i < color.length; i++) {
			outPrint += "<option>";
			outPrint += color[i];
			outPrint += "</option>";
		}
		outPrint += "</select>";
		out.print(outPrint);
	} catch (java.io.IOException e) {
		throw new JspTagException(e.getMessage());
	}
}
 
Example #13
Source File: ValuesTag.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public int doEndTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {
        if (!"-1".equals(objectValue)) {
            out.print(objectValue);
        } else if (!"-1".equals(stringValue)) {
            out.print(stringValue);
        } else if (longValue != -1) {
            out.print(longValue);
        } else if (doubleValue != -1) {
            out.print(doubleValue);
        } else {
            out.print("-1");
        }
    } catch (IOException ex) {
        throw new JspTagException("IOException: " + ex.toString(), ex);
    }
    return super.doEndTag();
}
 
Example #14
Source File: UrlTag.java    From subsonic with GNU General Public License v3.0 6 votes vote down vote up
public int doEndTag() throws JspException {

        // Rewrite and encode the url.
        String result = formatUrl();

        // Store or print the output
        if (var != null)
            pageContext.setAttribute(var, result, PageContext.PAGE_SCOPE);
        else {
            try {
                pageContext.getOut().print(result);
            } catch (IOException x) {
                throw new JspTagException(x);
            }
        }
        return EVAL_PAGE;
    }
 
Example #15
Source File: UploadTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
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 #16
Source File: ChooseTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
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 #17
Source File: TagUtils.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * INTERNAL: Creates the field name used by a particular action and
 * registers the data used by the action in the user session.
 */
public static String registerData(PageContext pageContext,
                                  String action_name, String group_name,
                                  String params, Set value)
  throws JspTagException {

  return registerData(pageContext, action_name, group_name, params, null,
                      value);
}
 
Example #18
Source File: NameTag.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public Collection process(Collection topics) throws JspTagException {
  if (topics == null || topics.isEmpty())
    return Collections.EMPTY_SET;
  else {      
    // find the most appropiate name for each of the topics in the collection
    ArrayList names = new ArrayList();
    
    // if no customer name grabber, setup the name grabber right here, right now.
    if (nameGrabber == null && basenameScopeVarName != null) {
      Collection scope = contextTag.getContextManager().getValue(basenameScopeVarName);
      // if name should be grabbed in accordance with scope  
      if (scope != null) 
        nameGrabber = new NameGrabber(scope);
    }
    if (nameGrabber == null)
      nameGrabber = TopicCharacteristicGrabbers.getDisplayNameGrabber();

    // iterate through topics
    Iterator iter = topics.iterator();
    Object obj = null;
    while (iter.hasNext()) {
      obj = iter.next();
      if (obj instanceof TopicIF) {
        Object name = nameGrabber.grab(obj);
        if (name != null)
          names.add(name);
      }
    } // while
    return names;
  }
}
 
Example #19
Source File: TabsTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
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 #20
Source File: CkeditorTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
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 #21
Source File: DeclareTag.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * Process the end tag.
 */
@Override
public int doEndTag() throws JspException {
  ContextTag contextTag = FrameworkUtils.getContextTag(pageContext);
  
  if (contextTag == null)
    throw new JspTagException("<tolog:declare> must be nested directly or"
            + " indirectly within a <tolog:context> tag, but no"
            + " <tolog:context> tag was found.");
  
  // get topicmap object on which we should compute 
  TopicMapIF topicmap = contextTag.getTopicMap();
  if (topicmap == null)
    throw new NavigatorRuntimeException("DeclareTag found no "
            + "topic map.");

  DeclarationContextIF declarationContext = contextTag
          .getDeclarationContext();
  try {
    declarationContext = QueryUtils.parseDeclarations(topicmap, declarations,
            declarationContext);
    
  } catch (InvalidQueryException e) {
    throw new JspTagException(e.getMessage());
  }
  contextTag.setDeclarationContext(declarationContext);
                
  return EVAL_PAGE;
}
 
Example #22
Source File: TagUtils.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * INTERNAL: Creates the field name used by a particular action and
 * registers the data used by the action in the user session.
 */
public static String registerData(PageContext pageContext,
                                  String action_name, String group_name,
                                  List paramlist, List sub_actions, Set value) 
  throws JspTagException {
  return registerData(pageContext, action_name, group_name, paramlist, sub_actions,
                      value, false, true);
}
 
Example #23
Source File: ComboBoxTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
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 #24
Source File: FooTag.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public int doAfterBody() throws JspException {
    try {
        if (i == 3) {
            bodyOut.writeOut(bodyOut.getEnclosingWriter());
            return SKIP_BODY;
        }

        pageContext.setAttribute("member", atts[i]);
        i++;
        return EVAL_BODY_BUFFERED;
    } catch (IOException ex) {
        throw new JspTagException(ex.toString());
    }
}
 
Example #25
Source File: LogTag.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public int doAfterBody() throws JspException {
    try {
        String s = bodyOut.getString();
        System.err.println(s);
        if (toBrowser)
            bodyOut.writeOut(bodyOut.getEnclosingWriter());
        return SKIP_BODY;
    } catch (IOException ex) {
        throw new JspTagException(ex.toString());
    }
}
 
Example #26
Source File: IfThenTag.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {
  // we have already checked the condition in doStartTag
  try {
    BodyContent body = getBodyContent();
    JspWriter out = body.getEnclosingWriter();
    out.print( body.getString() );
    body.clearBody();
  } catch (IOException e) {
    throw new NavigatorRuntimeException("Problem occurred when writing to JspWriter in logic:then.", e);
  }

  return SKIP_BODY;
}
 
Example #27
Source File: ChooseTag.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * Process the end tag.
 */
@Override
public int doEndTag() throws JspException {
  // establish old lexical scope, back to outside of the loop
  FrameworkUtils.getContextTag(pageContext).getContextManager().popScope();

  if (!foundWhen())
    throw new JspTagException("<tolog:choose> : must have one or more"
            + " <tolog:when> tags nested within it, but none were found.\n");
  
  return EVAL_PAGE;
}
 
Example #28
Source File: AutocompleteTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
public int doEndTag() throws JspTagException {
	try {
		JspWriter out = this.pageContext.getOut();
		out.print(end().toString());
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
Example #29
Source File: BindTag.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected final int doStartTagInternal() throws Exception {
	String resolvedPath = getPath();
	if (!isIgnoreNestedPath()) {
		String nestedPath = (String) pageContext.getAttribute(
				NestedPathTag.NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
		// only prepend if not already an absolute path
		if (nestedPath != null && !resolvedPath.startsWith(nestedPath) &&
				!resolvedPath.equals(nestedPath.substring(0, nestedPath.length() - 1))) {
			resolvedPath = nestedPath + resolvedPath;
		}
	}

	try {
		this.status = new BindStatus(getRequestContext(), resolvedPath, isHtmlEscape());
	}
	catch (IllegalStateException ex) {
		throw new JspTagException(ex.getMessage());
	}

	// Save previous status values, for re-exposure at the end of this tag.
	this.previousPageStatus = pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
	this.previousRequestStatus = pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);

	// Expose this tag's status object as PageContext attribute,
	// making it available for JSP EL.
	pageContext.removeAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
	pageContext.setAttribute(STATUS_VARIABLE_NAME, this.status, PageContext.REQUEST_SCOPE);

	return EVAL_BODY_INCLUDE;
}
 
Example #30
Source File: QueryExecutingTag.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * Print the body content to the enclosing writer.
 * Return SKIP_BODY by default.
 */
@Override
public int doAfterBody() throws JspTagException {
  // put out the evaluated body
  try {
    BodyContent body = getBodyContent();
    body.getEnclosingWriter().print( body.getString() );
  } catch (IOException ioe) {
    throw new NavigatorRuntimeException("Error in QueryExecutingTag.", ioe);
  }

  // Skip the body by default.
  return SKIP_BODY;
}