JavaServer Page

March 12, 2007

Iterating with tags 101 } protected void parseElements()

Filed under: JSP Tag Libraries — webmaster @ 2:22 am

Iterating with tags 101 } protected void parseElements() throws JspException { List l = new LinkedList(); StringTokenizer st = new StringTokenizer(elements, “,”); e while(st.hasMoreTokens()) { l.add(st.nextToken()); } elementsList = l.iterator(); } public int doAfterBody() throws JspException { try { getBodyContent().writeOut(getPreviousOut()); getBodyContent().clear(); } catch(java.io.IOException ioe) { // User probably disconnected … log(ls.getStr(Constants.IO_ERROR), ioe); throw new JspTagException(ls.getStr(Constants.IO_ERROR)); } f if(elementsList.hasNext()) { g pageContext.setAttribute(id, elementsList.next()); return EVAL_BODY_TAG; } return SKIP_BODY; } protected void clearProperties() { id = null; elements = null; super.clearProperties(); } protected void clearServiceState() { elementsList = null; } } B Parses the list of strings into a Java list and creates an enumerator. C If we have an element in the list, continues the body evaluation; otherwise skips the body (empty iteration). D Sets the iterator variable with the first element in the list.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Java Web Hosting