JSP actions use constructs in XML syntax to control the behavior of the servlet engine.
We would explain the JSP directive in a separate chapter JSP - Directives JSP Actions Includes a file during the translation phase.ĭeclares a tag library, containing custom actions, used in the page There are three types of directive tag − S.No.ĭefines page-dependent attributes, such as scripting language, error page, and buffering requirements. Ignored by the JSP engine.Ī single quote in an attribute that uses single quotes.Ī double quote in an attribute that uses double quotes.Ī JSP directive affects the overall structure of the servlet class. There are a small number of special constructs you can use in various cases to insert comments or characters that would otherwise be treated specially.
The above code will generate the following result − A Test of Comments A JSP comment is useful when you want to hide or "comment out", a part of your JSP page.įollowing is the syntax of the JSP comments −įollowing example shows the JSP Comments − JSP comment marks text or statements that the JSP container should ignore. The above code will generate the following result − The expression element can contain any expression that is valid according to the Java Language Specification but you cannot use a semicolon to end an expression.įollowing is the syntax of JSP Expression −įollowing example shows a JSP Expression − You must declare the variable or method before you use it in the JSP file.įollowing is the syntax for JSP Declarations −įollowing is an example for JSP Declarations −Ī JSP expression element contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file.īecause the value of an expression is converted to a String, you can use an expression within a line of text, whether or not it is tagged with HTML, in a JSP file. Browse through the same using URL The above code will generate the following result − JSP DeclarationsĪ declaration declares one or more variables or methods that you can use in Java code later in the JSP file. Let us keep the above code in JSP file hello.jsp and put this file in C:\apache-tomcat7.0.2\webapps\ROOT directory. NOTE − Assuming that Apache Tomcat is installed in C:\apache-tomcat-7.0.2 and your environment is setup as per environment setup tutorial. Following is the simple and first example for JSP − You can write the XML equivalent of the above syntax as follows −Īny text, HTML tags, or JSP elements you write must be outside the scriptlet. The elements of JSP have been described below − The ScriptletĪ scriptlet can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting language. We will understand the basic use of simple syntax (i.e, elements) involved with JSP development. pageContext instance by default provided by TagSupport class.In this chapter, we will discuss Syntax in JSP. Writing data for the JSP file we must use the JspWriter class.getOut() method provided by the PageContext class and it returns the instance of JspWrite class. Create the tag Handler class must extend the TagSupport class and overriding its method doStartTag().
It creates the Tag Handler class and this class performs the action at the start or at the end of the tag. The preparation of the custom tag needs 3 elements. end tag Preparation of Custom Tag in JSP
Web development, programming languages, Software testing & others
Start Your Free Software Development Course