JSP Directives


Directives provide instructions to the JSP container and affect compiling of the JSP page.

Though there are mainly three types of directives named as ‘page directive’, ‘include directive, and ‘taglib directive’, but I am going to cover few more along with them.

[table caption=”JSP Directives Table” width=”750″ colwidth=”10|50|50|50″ colalign=”left|left|left|left”]
no.,JSP Element,Syntax,Interpretation
1,JSP Expression,<%= expression %>, expression is evaluated and placed in output.
2,JSP Scriplets,<% code %>, code is inserted in service() method.
3,JSP Declaration,<%! code %>, code is inserted in the body of servlet class – outside of service method.
4,JSP Page Directive,<%@ page att=”val” %>, Directions to the servlet engine about general setup.
5,JSP Include Directive,<%@ include file=”url” %>, A file on the local system to be included when JSP page is translated into servlet.
6,JSP Comment,<%– Comment –%>, Comments ignored when JSP converted into Servlet.
7,JSP Taglib,<%@ taglib … %>, declares a tag library containing custom actions – used in the page.

Previous articleCloning in Java
Next articleException Handling
I have spent almost 10 years playing around Java and related technologies. I love to write on different topics and would be very much willing to hear back your feedback/suggestions on them. This site is a medium to share my knowledge with the Java folks and grow further. My other interests include traveling, driving, swimming and dance. But yes, my web site has become my passion over the time :) I live in Scotland and travel to India often, my roots being there.