Sunteți pe pagina 1din 50

Lesson X: Advanced Topics

JSTL and Regular Expressions

JSP Standard Library Tags

JSTL

JSTL

JSTL

JSTL

JSTL
When you want to change the loops behaviour (iterate only over a subset or do counter+=2 ) you use the:
begin attribute end attribute step attribute

JSTL

JSTL

JSTL
When you want to set values that arent Bean properties or maps you can utilize the <c:set> tag. We need to differentiate between the target and var types. target is for bean properties and maps and var is for variables.

JSTL

JSTL

JSTL

JSTL

JSTL
It is impossible to have both target and var in your <c:set> tag. The default scope value is page. When value is null, the value for var will be removed.

JSTL
When target is null, the container throws an exception. target can only accommodate object values. You cant pass in ids and names that will evaluate to objects.

An exception is thrown when target is neither an object or a Map.

Remove Tag

Remove Tag

Import Tag

Import Tag
Normally when doing imports, you can only fetch pages within the webapp, with the import jstl tag you can go outside of the application and fetch data.

Import Tag

Import Tag

The url Tag

The url Tag

Error Pages

Error Pages

Error Pages

The <error-page> DD tag

The <error-page> DD tag

The <error-page> DD tag

The <error-page> DD tag


Error pages are basically just jsps than handle exceptions, so they are also given additional implicit objects for us to use. In this case we are given the exception implicit object to play around with.

The <error-page> DD tag

The <error-page> DD tag

The <c:catch> DD tag

The <c:catch> DD tag

JSTL Tags

Custom Tag Libraries


Not all custom tag libraries will come well documented as the JSTL core libraries, so well have to discuss on the syntax of tag libraries. In the tag <c:set>, c is the prefix and set is the name. You also have to aware of the library URI

Regular Expressions
Regular expressions are pattern matching standards for spring parsing and replacement. Please take note that not all implementations of regular expressions are the same, and there might be different ways to express a certain combination.

Example

Quantifiers
* - matches any number of whats before, zero to infinity ? matches zero to one + - matches at least one

Example

Behaviour
As far as we are concerned, regexs are always greedy taking in as much number of a certain character there is. The example right after shows us this.

Example

Other Representations

Example

Character Classes

Example

Grouping

Example

Sources
http://www.aivosto.com/vbtips/regex.html

S-ar putea să vă placă și