By: aathishankaran Viewed: 153175 times
The important syntax elements of JSP are tags. The JSP tags do not use <%, but just the < character.
A JSP tag is somewhat like an HTML tag. JSP tags can have a "start tag", a "tag body" and an "end tag". The start and end tag both use the tag name, enclosed in < and > characters. The end starts with a / character after the < character. The tag names have an embedded colon character : in them, the part before the colon describes the type of the tag.
If the tag does not require a body, the start and end can be conveniently merged together, as
Here by closing the start tag with a /> instead of > character, we are ending the tag immediately, and without a body. (This syntax convention is the the same as XML.)
Tags can be of two types: loaded from an external tag library, or predefined tags. Predefined tags start with jsp: characters. For instance, jsp:include is a predefined tag that is used to include other pages.
We have already seen the include directive in previous examples. jsp:include is similar. But instead of loading the text of the included file in the original file, it actually calls the included target at run-time (the way a browser would call the included target. In practice, this is actually a simulated request rather than a full round-trip between the browser and the server).
Following is an example of jsp:include usage
Going to include hello.jsp...<BR>
Try it and see what you get. Now change the "jsp:include" to "jsp:forward" and see what is the difference. These two predefined tags are frequently very useful.
Most Viewed Articles (in JSP )
Latest Articles (in JSP)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews