InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.2: Developing JSP files >
4.2.2.3: Overview of JSP file content >
4.2.2.3.1: JSP syntax: JSP directives
4.2.2.3.1: JSP syntax: JSP directives
Use JSP directives (enclosed within <%@ and %>) to specify:
- Scripting language being used
- Interfaces a servlet implements
- Classes a servlet extends
- Packages a servlet imports
- MIME type of the generated response
For more information on the JSP 1.1 technologies, view the
Tomcat
documentation at the SunTM site.
The general syntax of the JSP directive is:
<%@ directive_name ="value" %>
where the valid directive names are:
- language
The scripting language used in the file. At this time, the only
valid value and the default value is java (the Java programming
language). The scope of this directive is the JSP file.
When used more than once, only the first occurrence of the directive is
significant. An example:
<%@ language ="java" %>
- method
The name of the method generated by the embedded Java code
(scriptlet). The generated code becomes the body of the specified
method name. The default method is service. When used
more than once, only the first occurrence of the directive is
significant. An example:
<%@ method ="doPost" %>
- import
A comma-separated list of Java language package names or class names that
the servlet imports. This directive can be specified multiple times
within a JSP file to import different packages. An example:
<%@ import ="java.io.*,java.util.Hashtable" %>
- content_type
The MIME type of the generated response. The default value is
text/html. This information is used to generate the response header. When used more than once, only the first occurrence of this
directive is significant. This directive can be used to specify the character set in which the page
is to be encoded. An example:
<%@ content_type ="text/html; charset=iso-8859-1" %>
- implements
A comma-separated list of Java language interfaces that the generated
servlet implements. You can use this directive more than once within a
JSP file to implement different interfaces. An example:
<%@ implements ="javax.servlet.http.HttpSessionContext" %>
- extends
The name of the Java language class that the servlet extends. The
class must be a valid class and does not have to be a servlet class.
The scope of this directive is the JSP file. When used more
than once, only the first occurrence of the directive is significant.
An example:
<%@ extends ="javax.servlet.http.HttpServlet" %>
|
|