Switch to full style
What's behind JSP & Servlets
Post a reply

JSP Tutorial 101

Tue Dec 07, 2010 10:48 pm

What Is a JSP Page?

A JSP page is a text document that contains two types of text: static data, which can be expressed in any text-based format (such as HTML, SVG, WML, and XML), and JSP elements, which construct dynamic content.

The recommended file extension for the source file of a JSP page is .jsp. The page can be composed of a top file that includes other files that contain either a complete JSP page or a fragment of a JSP page. The recommended extension for the source file of a fragment of a JSP page is .jspf.

The JSP elements in a JSP page can be expressed in two syntaxes--standard and XML--though any given file can use only one syntax. A JSP page in XML syntax is an XML document and can be manipulated by tools and APIs for XML documents. (Just like php <?php ?>, you can put <% %> jsp tags inside in the HTML, XML etc. pages.)

The lines in bold in the example code contain the following types of JSP constructs:

1. A page directive (<%@page ... %>) sets the content type returned by the page.
<%@ page contentType="text/html; charset=UTF-8" %>
2. Tag library directives (<%@taglib ... %>) import custom tag libraries.
<%@ taglib uri="/WEB-INF/functions.tld" prefix="f" %>
3. jsp:useBean creates an object containing a collection of locales and initializes an identifier that points to that object.
<jsp:useBean id="locales" scope="application" class="mypkg.MyLocales"/>
4. JSP expression language expressions (${ }) retrieve the value of object properties. The values are used to set custom tag attribute values and create dynamic content.
<c:if test="${selectedFlag}" >
5. Custom tags set a variable (c:set), iterate over a collection of locale names (c:forEach), and conditionally insert HTML text into the response (c:if, c:choose, c:when, c:otherwise).
6. jsp:setProperty sets the value of an object property.
7. A function (f:equals) tests the equality of an attribute and the current item of a collection. (Note: A built-in == operator is usually used to test equality).

Next Tutorial - Introduction to Web Applications.



Post a reply
  Related Posts  to : JSP Tutorial 101
 JSP tutorial     -  
 SEO Tutorial     -  
 C Tutorial     -  
 photoshop tutorial     -  
 Brewing Java: A Tutorial     -  
 java assertions video tutorial     -  
 Java Reverse Engineering Tutorial.pdf     -