类javax.servlet.jsp.JspTagException源码实例Demo

下面列出了怎么用javax.servlet.jsp.JspTagException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Tomcat8-Source-Read   文件: ValuesTag.java
@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();
}
 
源代码2 项目: airsonic-advanced   文件: UrlTag.java
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;
    }
 
源代码3 项目: openemm   文件: PermissionTag.java
/**
 * 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;
	}
}
 
源代码4 项目: Online-Library-System   文件: SearchByTag.java
/**
 * 为搜书功能中添加下拉框
 */
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());
	}
}
 
源代码5 项目: Online-Library-System   文件: BookLocationTag.java
/**
 * 为添加书本中的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());
	}
}
 
源代码6 项目: unitime   文件: SectionTitle.java
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;
}
 
源代码7 项目: ontopia   文件: AttributeTag.java
/**
 * 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;
}
 
源代码8 项目: airsonic   文件: UrlTag.java
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;
    }
 
源代码9 项目: tomcatsrc   文件: ValuesTag.java
@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();
}
 
源代码10 项目: ontopia   文件: TopicMapReferencesTag.java
/**
 * 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;
}
 
源代码11 项目: ontopia   文件: OtherwiseTag.java
/**
 * 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;
}
 
源代码12 项目: tomcatsrc   文件: ValuesTag.java
@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();
}
 
源代码13 项目: subsonic   文件: UrlTag.java
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;
    }
 
源代码14 项目: ontopia   文件: ReifierTag.java
@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;
  }
}
 
源代码15 项目: ontopia   文件: IfElseTag.java
/**
 * Process the start tag for this instance.
 */
@Override
public int doStartTag() throws JspTagException {
  this.ifTagParent = (IfTag) findAncestorWithClass(this, IfTag.class);
  if (ifTagParent == null) {
    throw new JspTagException("logic:else is not inside logic:if.");
  }

  if (ifTagParent.matchCondition())
    return SKIP_BODY;
  else
    return EVAL_BODY_BUFFERED;
}
 
源代码16 项目: ontopia   文件: QueryWrapper.java
/** 
 * Bind (some of) the names of the columns of the result to the current row. 
 * Only bind those columns corresponding to a true entry in groupColumns.
 * e.g. column 3 is bound if groupColumns[3] is true.
 */
protected void bindVariables(boolean groupColumns[]) throws JspTagException {
  String columnNames[] = queryResult.getColumnNames();
  for (int i = 0; i < groupColumns.length; i++) {
    if (groupColumns[i]) {
      contextManager.setValue(columnNames[i]
              , currentRow[i] == null
              ? Collections.EMPTY_LIST
              : currentRow[i]);
    }
  }
}
 
源代码17 项目: Tomcat8-Source-Read   文件: Util.java
/**
 * Utility methods
 * taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
 * @param url The URL
 * @param context The context
 * @param pageContext The page context
 * @return the absolute URL
 * @throws JspException If the URL doesn't start with '/'
 */
public static String resolveUrl(
        String url, String context, PageContext pageContext)
throws JspException {
    // don't touch absolute URLs
    if (isAbsoluteUrl(url))
        return url;

    // normalize relative URLs against a context root
    HttpServletRequest request =
        (HttpServletRequest) pageContext.getRequest();
    if (context == null) {
        if (url.startsWith("/"))
            return (request.getContextPath() + url);
        else
            return url;
    } else {
        if (!context.startsWith("/") || !url.startsWith("/")) {
            throw new JspTagException(
            "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
        }
        if (context.equals("/")) {
            // Don't produce string starting with '//', many
            // browsers interpret this as host name, not as
            // path on same host.
            return url;
        } else {
            return (context + url);
        }
    }
}
 
源代码18 项目: unitime   文件: BackTree.java
public int doStartTag() throws JspException {
	try {
		pageContext.getOut().print(
				BackTracker.getBackTree((HttpServletRequest)pageContext.getRequest())
			);
	} catch (Exception e) {
		throw new JspTagException(e.getMessage());
	}
	return SKIP_BODY;
}
 
源代码19 项目: unitime   文件: SessionContextTag.java
@Override
public int doStartTag() throws JspTagException {
	pageContext.setAttribute(
			"sessionContext",
			WebApplicationContextUtils.getWebApplicationContext(this.pageContext.getServletContext()).getBean("sessionContext")
			);
	return EVAL_BODY_INCLUDE;
}
 
源代码20 项目: airsonic-advanced   文件: ParamTag.java
public int doEndTag() throws JspTagException {

        // Add parameter name and value to surrounding 'url' tag.
        UrlTag tag = (UrlTag) findAncestorWithClass(this, UrlTag.class);
        if (tag == null) {
            throw new JspTagException("'sub:param' tag used outside 'sub:url'");
        }
        tag.addParameter(name, value);
        return EVAL_PAGE;
    }
 
源代码21 项目: ontopia   文件: SubclassesTag.java
@Override
public Collection process(Collection topics) throws JspTagException {
  // find all subclasses of all topics in collection
  if (topics == null || topics.isEmpty())
    return Collections.EMPTY_SET;
  else {
    HashSet subclasses = new HashSet();
    Iterator iter = topics.iterator();
    TopicIF topic = null;
    Object obj = null;
    while (iter.hasNext()) {
      obj = iter.next();
      try {
        topic = (TopicIF) obj;
      } catch (ClassCastException e) {
        throw new NavigatorRuntimeException("SubclassesTag expected to get a input collection of " +
          "topic instances, but got instance of class " + obj.getClass().getName());
      }

      // the topic casting succeeded, now find the subclasses
      if (levelNumber == null)
        subclasses.addAll( hierUtils.getSubclasses(topic) );
      else
        subclasses.addAll( hierUtils.getSubclasses(topic,
                           levelNumber.intValue()));
      
    } // while
    return subclasses;
  }
}
 
源代码22 项目: ontopia   文件: FulltextTag.java
@Override
public Collection process(Collection tmObjects) throws JspTagException {

  // Get topic map
  ContextTag contextTag = FrameworkUtils.getContextTag(pageContext);    

  // Get topic map from context
  TopicMapIF topicmap = contextTag.getTopicMap();
  String tmid = contextTag.getTopicMapId();
  
  if (topicmap == null)
    throw new NavigatorRuntimeException("FulltextTag found no topic map.");

  try {
    // Output debugging information
    if (log.isDebugEnabled()) {
      log.debug("Query: '" + query + "'");
    }
    
    // Create search engine
    SearcherIF sengine = (SearcherIF) topicmap.getIndex(SearcherIF.class.getName());
    if (sengine == null) {
      throw new NavigatorRuntimeException("Topicmap " + tmid + " has no SearcherIF index");
    }

    // Perform search
    TopicMapSearchResult result = new TopicMapSearchResult(topicmap, sengine.search(query));

    // Set object id field
    if (idfield != null) result.setObjectIdField(idfield);

    // Return search result
    return result;
  } catch (java.io.IOException e) {
    throw new OntopiaRuntimeException(e);
  }
}
 
源代码23 项目: ontopia   文件: WhenTag.java
/** 
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {
  parentChooser.setFoundMatchingWhen();
  
  return super.doAfterBody();
}
 
源代码24 项目: openemm   文件: ComShowColumnInfoTag.java
/**
 * Shows column information.
 */
@Override
public int doStartTag() throws JspTagException {
	try {
		if (iteratorID == null) {
			iteratorID = "";
		}

		if (table == 0) {
			table = AgnUtils.getAdmin(pageContext).getCompany().getId();
		}

		List<ComProfileField> comProfileFieldMap = getColumnInfoService().getComColumnInfos(table, AgnUtils.getAdmin(pageContext).getAdminID(), useCustomSorting);

		if (comProfileFieldMap.size() <= 0) {
			return SKIP_BODY;
		} else {
			pageContext.setAttribute("__" + iteratorID + "_data", comProfileFieldMap.iterator());
			pageContext.setAttribute("__" + iteratorID + "_map", comProfileFieldMap);
			pageContext.setAttribute("__" + iteratorID + "_colmap", comProfileFieldMap);
			return doAfterBody();
		}
	} catch (Exception e) {
		logger.error("Error in ComShowColumnInfoTag.doStartTag", e);
		throw new JspTagException("Error: " + e);
	}
}
 
源代码25 项目: ontopia   文件: ClassesOfTag.java
@Override
public Collection process(Collection tmObjects) throws JspTagException {
  // find all the classes of all tmObjects in collection
  // avoid duplicate type entries therefore use a 'Set'
  if (tmObjects == null)
    return Collections.EMPTY_SET;
  else{
    Set types = new HashSet();
    Iterator iter = tmObjects.iterator();
    Object obj = null;
    while (iter.hasNext()) {
      obj = iter.next();
      // --- for occurrence, association, or association role objects
      if (obj instanceof TypedIF) {
        TypedIF singleTypedObj = (TypedIF) obj;
        TopicIF type = singleTypedObj.getType();
        if (type != null)
          types.add( type );
      }
      // --- for topic objects
      else if (obj instanceof TopicIF) {
        TopicIF topic = (TopicIF) obj;
        Collection _types = topic.getTypes();
        if (!_types.isEmpty())
          types.addAll( _types );
      }
    } // while    
    return new ArrayList(types);
  }
}
 
源代码26 项目: java-technology-stack   文件: MessageTag.java
/**
 * Resolve the specified message into a concrete message String.
 * The returned message String should be unescaped.
 */
protected String resolveMessage() throws JspException, NoSuchMessageException {
	MessageSource messageSource = getMessageSource();

	// Evaluate the specified MessageSourceResolvable, if any.
	if (this.message != null) {
		// We have a given MessageSourceResolvable.
		return messageSource.getMessage(this.message, getRequestContext().getLocale());
	}

	if (this.code != null || this.text != null) {
		// We have a code or default text that we need to resolve.
		Object[] argumentsArray = resolveArguments(this.arguments);
		if (!this.nestedArguments.isEmpty()) {
			argumentsArray = appendArguments(argumentsArray, this.nestedArguments.toArray());
		}

		if (this.text != null) {
			// We have a fallback text to consider.
			String msg = messageSource.getMessage(
					this.code, argumentsArray, this.text, getRequestContext().getLocale());
			return (msg != null ? msg : "");
		}
		else {
			// We have no fallback text to consider.
			return messageSource.getMessage(
					this.code, argumentsArray, getRequestContext().getLocale());
		}
	}

	throw new JspTagException("No resolvable message");
}
 
源代码27 项目: ontopia   文件: SuperclassesTag.java
@Override
public Collection process(Collection topics) throws JspTagException {
  // find all superclasses of all topics in collection
  if (topics == null || topics.isEmpty())
    return Collections.EMPTY_SET;
  else {
    HashSet superclasses = new HashSet();
    Iterator iter = topics.iterator();
    TopicIF topic = null;
    Object obj = null;

    while (iter.hasNext()) {
      obj = iter.next();
      try {
        topic = (TopicIF)obj;
      } catch (ClassCastException e) {
        String msg = "SubclassesTag expected to get a input collection of " +
          "topic instances, " +
          "but got instance of class " + obj.getClass().getName();
        throw new NavigatorRuntimeException(msg);
      }

      // ok, the topic cast succeeded, now continue
      if (levelNumber == null)
        // if no level is specified get all of them.
        superclasses.addAll(hierUtils.getSuperclasses(topic));
      else 
        superclasses.addAll(hierUtils.getSuperclasses(topic, levelNumber.intValue()));

    } // while
    return superclasses;
  }
}
 
源代码28 项目: oslits   文件: DoubleSubmitTag.java
@SuppressWarnings("unchecked")
public int doStartTag()	throws JspException {
	StringBuilder buffer = new StringBuilder();
	
	HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
	HttpSession session = request.getSession();
	
	Map<String, String> map = null;
	
	if (session.getAttribute(EgovDoubleSubmitHelper.SESSION_TOKEN_KEY) == null) {
		map = new HashMap<String, String>();
		
		session.setAttribute(EgovDoubleSubmitHelper.SESSION_TOKEN_KEY, map);
	} else {
		map = (Map<String, String>) session.getAttribute(EgovDoubleSubmitHelper.SESSION_TOKEN_KEY);
	}
			
	// First call (check session)
	if (map.get(tokenKey) == null) {
		
		map.put(tokenKey, EgovDoubleSubmitHelper.getNewUUID());

		LOGGER.debug("[Double Submit] session token created({}) : {}", tokenKey, map.get(tokenKey)); 
	}
	
	buffer.append("<input type='hidden' name='").append(EgovDoubleSubmitHelper.PARAMETER_NAME).append("' value='").append(map.get(tokenKey)).append("'/>");
	
	try {
		pageContext.getOut().print(buffer.toString());
	} catch (IOException e) {
		throw new JspTagException("Error:  IOException while writing to the user");
	}
	
       return SKIP_BODY;
}
 
源代码29 项目: airsonic   文件: EscapeJavaScriptTag.java
public int doEndTag() throws JspException {
    try {
        pageContext.getOut().print(StringEscapeUtils.escapeJavaScript(string));
    } catch (IOException x) {
        throw new JspTagException(x);
    }
    return EVAL_PAGE;
}
 
源代码30 项目: airsonic   文件: FormatBytesTag.java
public int doEndTag() throws JspException {
    Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest());
    String result = StringUtil.formatBytes(bytes, locale);

    try {
        pageContext.getOut().print(result);
    } catch (IOException x) {
        throw new JspTagException(x);
    }
    return EVAL_PAGE;
}
 
 类所在包
 同包方法