Chapter 14. Struts Logic Tags: Conditional Presentation Logic


IN THIS CHAPTER

  • Using Struts Logic Tags That Perform Conditional Display Based on a Value

  • Using Struts Logic Tags That Match Substrings

  • Using the Struts Logic Tags for Iteration

  • Using the Struts Logic Tags to Test for Absence or Presence of Values

  • Using the Struts Logic Tags to Transfer Control

  • Conclusions

Sometimes you need to control whether something is displayed on the JSP page. In traditional JSP, you must break out into a scriptlet to do this, wrapping HTML in an if (or perhaps a for loop to iterate).

The struts:logic taglib provides a tag-based alternative to scriptlets that can handle many common conditional cases. However, some of these tags can be a bit tricky to use. You might still find that you must break out into Java to handle some of the more complex requirements of your application. When JSTL is fully integrated into JSP, you'll finally be able to do almost everything without needing to do this.

You can find all the files used here in the StrutsTaglib Web application. The main JSP page for this chapter, shown in Figure 14.1 is located at the URL http://myAppServer/StrutsTaglibs/logic.jsp .

Figure 14.1. The sample applications for Chapter 14.

graphics/14fig01.jpg

Note

In all URLs in the chapter, replace myAppServer with the hostname and port that you've configured your JSP server to run on. For Tomcat, this is usually localhost:8080.




Struts Kick Start
Struts Kick Start
ISBN: 0672324725
EAN: 2147483647
Year: 2002
Pages: 177

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net