lunes, 9 de febrero de 2009

JSTL: la especificacion de JSPs trae JSTL

Tag=Etiqueta=Componente Web

JSP = Java Server Pages
JSTL = Java Standard Tag Library

http://jakarta.apache.org/taglibs/site/tutorial.html


Tutorial de SUN: http://java.sun.com/j2ee/1.3/docs/tutorial/doc/JSTL.html

La especificación JSP viene acompañada de la especificación JSTL, cuyo finalidad es no escribir codigo java en la vista (codigo HTML) para seguir utilizando una pseudosintaxis HTML.

proyecto jsps+jstls en repo


Instalación:
  • incluir librerias en WEB-INF/lib incluidas en jakarta-taglibs-standard-1.0.6/lib
  • incluir documentos descriptores de librerías (tlds*) desde jakarta-taglibs-standard-1.0.6/tld hasta nuestroProyecto/WebContent/tld
  • definir en web.xml los tlds que vamos a utilizar en nuestro jsp

Novedades incluidas:



Implicit Objects

The JSTL expression language defines a set of implicit objects:

  • pageContext - the PageContext object
  • pageScope - a Map that maps page-scoped attribute names to their values
  • requestScope - a Map that maps request-scoped attribute names to their values
  • sessionScope - a Map that maps session-scoped attribute names to their values
  • applicationScope - a Map that maps application-scoped attribute names to their values
  • param - a Map that maps parameter names to a single String parameter value (obtained by calling ServletRequest.getParameter(String))
  • paramValues - a Map that maps parameter names to a String[ ] of all values for that parameter (obtained by calling ServletRequest.getParameterValues(String))
  • header - a Map that maps header names to a single String header value (obtained by calling ServletRequest.getheader(String))
  • headerValues - a Map that maps header names to a String[ ] of all values for that parameter (obtained by calling ServletRequest.getHeaders(String))
  • cookie - a Map that maps cookie names to a single Cookie (obtained by calling HttpServletRequest.getCookie(String))
  • initParam - a Map that maps a parameter names to a single String parameter value (obtained by calling ServletRequest.getInitParameter(String))



** el uri es el identificativo: http://code.google.com/p/cursoj2ee/source/detail?r=88





JSTL -> especificación extensible->herencia->etiquetas personalizadas..
pasos a seguir para realizar una etiqueta o librería de etiquetas personalizadas...
  1. crear la clase java que hereda de tag
  2. crear (si no existe el tld) e incluir el tag recien creado
  3. incluir el tld en el web.xml
  4. incluir el tld en el jsp
  5. usar el tag en el jsp
http://groups.google.com/group/eticom-master-java/web/jstl-y-etiquetas-personalizadas-2




ejemplo c:foreach


No hay comentarios:

Publicar un comentario