JSP directives
The jsp directives are messages that tells the web container how to translate a JSP page into the corresponding servlet.
There are three types of directives:
page directive
include directive
taglib directive
Syntax of JSP Directive
<%@ directive attribute="value" %>
SP page directive
The page directive defines attributes that apply to an entire JSP page.
Syntax of JSP page directive
<%@ page attribute="value" %>
Attributes of JSP page directive
import
contentType
extends
info
buffer
language
isELIgnored
isThreadSafe
autoFlush
session
pageEncoding
errorPage
isErrorPage
1)import
The import attribute is used to import class,interface or all the members of a package.It is similar to import keyword in java class or interface.
Example of import attribute
<html>
<body>
<%@ page import="java.util.Date" %>
Today is: <%= new Date() %>
</body>
</html>
2)contentType
The contentType attribute defines the MIME(Multipurpose Internet Mail Extension) type of the HTTP response.The default value is "text/html;charset=ISO-8859-1".
Example of contentType attribute
<html>
<body>
<%@ page contentType="application/msword" %>
Today is: <%= new java.util.Date() %>
</body>
</html>
3)extends
The extends attribute defines the parent class that will be inherited by the generated servlet.It is rarely used.
4)buffer
The buffer attribute sets the buffer size in kilobytes to handle output generated by the JSP page.The default size of the buffer is 8Kb.
Example of buffer attribute
<html>
<body>
<%@ page buffer="16kb" %>
Today is: <%= new java.util.Date() %>
</body>
</html>
6)language
The language attribute specifies the scripting language used in the JSP page. The default value is "java".
7)isELIgnored
We can ignore the Expression Language (EL) in jsp by the isELIgnored attribute. By default its value is false i.e. Expression Language is enabled by default. We see Expression Language later.
<%@ page isELIgnored="true" %>//Now EL will be ignored
8)isThreadSafe
Servlet and JSP both are multithreaded.If you want to control this behaviour of JSP page, you can use isThreadSafe attribute of page directive.The value of isThreadSafe value is true.If you make it false, the web container will serialize the multiple requests, i.e. it will wait until the JSP finishes responding to a request before passing another request to it.If you make the value of isThreadSafe attribute like:
<%@ page isThreadSafe="false" %>
The web container in such a case, will generate the servlet as:
public class SimplePage_jsp extends HttpJspBase
implements SingleThreadModel{
.......
}
9)errorPage
The errorPage attribute is used to define the error page, if exception occurs in the current page, it will be redirected to the error page.
Example of errorPage attribute
//index.jsp
<html>
<body>
<%@ page errorPage="myerrorpage.jsp" %>
<%= 100/0 %>
</body>
</html>
10)isErrorPage
The isErrorPage attribute is used to declare that the current page is the error page.
Note: The exception object can only be used in the error page.
Example of isErrorPage attribute
//myerrorpage.jsp
<html>
<body>
<%@ page isErrorPage="true" %>
Sorry an exception occured!<br/>
The exception is: <%= exception %>
</body>
</html>
Jsp Include Directive
=====================
The include directive is used to include the contents of any resource it may be jsp file, html file or text file. The include directive includes the original content of the included resource at page translation time (the jsp page is translated only once so it will be better to include static resource).
Advantage of Include directive
Code Reusability
Syntax of include directive
<%@ include file="resourceName" %>
Example of include directive
In this example, we are including the content of the header.html file. To run this example you must create an header.html file.
<html>
<body>
<%@ include file="header.html" %>
Today is: <%= java.util.Calendar.getInstance().getTime() %>
</body>
</html>
Note: The include directive includes the original content, so the actual page size grows at runtime.
JSP Taglib directive
====================
The JSP taglib directive is used to define a tag library that defines many tags. We use the TLD (Tag Library Descriptor) file to define the tags. In the custom tag section we will use this tag so it will be better to learn it in custom tag.
Syntax JSP Taglib directive
<%@ taglib uri="uriofthetaglibrary" prefix="prefixoftaglibrary" %>
Example of JSP Taglib directive
In this example, we are using our tag named currentDate. To use this tag we must specify the taglib directive so the container may get information about the tag.
<html>
<body>
<%@ taglib uri="WEB-INF/mytags.tld" prefix="mytags" %>
<mytags:today>
</body>
</html>
Followers
Amazon Web Services (AWS)
CoreJava
- coreJava : Core Java Index
- coreJava : Java Basics
- coreJava: Wrapper class
- coreJava: super keyword in java
- coreJava : constructor in java
- coreJava : final key word
- coreJava : this key word in java
- coreJava : packages in java
- coreJava : Access Modifiers in Java
- coreJava : Strings
- coreJava : Exception Handling
- coreJava : Exceptions Handling Interview questions...
- coreJava : Collections
- coreJava : Java Collections Interview Questions
- coreJava : Comparable Vs Comparator
- coreJava: Encapsulation in Java
- coreJava: Threads
- coreJava : Features of java 5.
- coreJava : Features of java
- coreJava : instanceof Operator
Spring IOC
- Spring
- springIOC: Overview and features
- springIOC: Containers
- springIOC: Beans Configuration file
- springIOC: Hello World (XML)
- springIOC: CI with primitive and String
- springIOC: CI with dependent object
- springIOC: CI with Collection
- springIOC: CI with Map
- springIOC: CI with properties
- springIOC: SI with primitive and String
- springIOC: SI with dependent object
- springIOC: SI with collection
- springIOC: SI with map
- springIOC: SI with properties
- springIOC : Difference between constructor and setter injection
- springIOC: Scopes
- springIOC: Spring Scopes(singleton)
- springIOC: Spring Scope (prototype)
- springIOC: Spring Bean Life Cycle
- springIOC: Spring Bean Life Cycle(default init and...
- springIOC: Inheritance(Super class is Abstract Class)
- springIOC: Inheritance(Super class is Concrete Cla...
- springIOC: Multiple Beans using XML (Type1)
- springIOC: Beans Life Cycle (Java)
- springIOC: Multiple Beans using XML (Type2)
- springIOC: Bean Life Cycle(Java Based)
- springIOC : autowire byName
- springIOC : autowire byType
- springIOC : autowire constructor
- springIOC: Hello World (Java Based)
- springIOC: Bean Life Cycle(XML Configuration)
- springIOC : @PostConstruct and @PreDestroy
- springIOC : @Required Annotation
- springIOC : @Autowired on constructor
- springIOC : @Autowired on Setter Method
- springIOC : @Autowired on Field
- springIOC : @Qualifier Annotation
- springIOC : Spring Interview Questions
spring MVC
- springMVC : Controllers
- springMVC : Spring MVC Execution Flow
- springMVC : BasicExample
- springMVC : BasicExample(InternalResourceViewResol...
- springMVC : MultipleRequestsMultipleHandlers
- springMVC : MutipleRequestsOneHandler
- springMVC : uri Template
- springMVC : Exception Handling using Annotation
- springMVC : Exception Handling using Interface
- spring MVC : interceptor
- springMVC : Multiple Interceptor
- springMVC : ResourceBundleViewResolver
- springMVC : Spring and Tiles Integration
- spring MVC : Spring Forms
- springMVC : Spring Form validation Using Validator...
- springMVC : Internationalization Using Automatic A...
- spring application
Spring DAO
- Home
- springdao : Overview Of Spring Dao
- springdao : jdbcTemplate class
- springdao : jdbcTemplate
- springdao : jdbcTemplate(PreparedStatement)
- springdao : jdbcTemplate (Annotation)
- springdao : ResultSetExtractor
- springdao : RowMapper
- springdao : NamedParameterJdbcTemplate
- springdao : SimpleJdbcTemplate
- springdao : Spring and Hibernate Integration
springAOP
- springAOP
- springAOP : Spring AOP Overview
- springAOP : spring AOP with Annotations
- springAOP : @Before
- springAOP : @After
- springAOP : @Around
- springAOP : @AfterThrowing
- springAOP : @AfterReturning
- springAOP : AOP with XML configuration
- springAOP : Before
- springAOP : After
- springAOP : Around
- springAOP : AfterThrowing
- springAOP : AfterReturning
Servlets
- Home
- Servlets : Basics
- Generic Servlet Example
- Servlet: Get Request Handling in Servlets
- Servlet: Post Request Handling in Servlet
- Servlet : load-on-startup / pre initialization of ...
- Servlet: Multiple Buttons in Servlet
- Servlet : ServletConfig
- Servlet: ServletContext
- Servlet : Session tracking techniques in servlet a...
- Servlet: Session tracking using HttpSession
- Servlet: Session tracking using Cookies
- Servlet: Session tracking using URLReWriting
- Servlet: Session tracking using HiddenFormFields
- Servlet: RequestDispatcher
- Servlet: SendRedirect
- Servlet:Filter
- Servlet : AnnotationServlet
JSP
- jsp : Life Cycle and Implicit Objects
- jsp : Scripting tags
- jsp : JSP directive Tags
- JSP:RequestDispatcher
- JSP: SendRedirect
- JSP: Session tracking using Cookies
- JSP: Session tracking using URLRewriting
- JSP: Session tracking using HiddenFormFields
- JSP: Session tracking using HttpSession
- JSP:Exception Handling
- JSP:Custom Tags (TagSupport1)
- jsp : Action Tags
- JSP : Beans in JSP application
- JSP:Custom Tags (TagSupport2)
- JSP:Custom Tags (TagSupport3)
- JSP:Custom Tags (BodyTagSupport)
- JSP:Custom Tags (BodyTagSupport with parameters)
- JSP
JBDC
- JDBC
- JDBC : Insertion using Statement Interface
- JDBC : Updation using Statement Interface
- JDBC : Deletion using Statement Interface
- JDBC: Insertion using PreparedStatement
- JDBC : Updation using PreParedStatement
- JDBC: selection using PreParedStatement
- JDBC: Scrollable Result Set
- JDBC: Updatable ResultSet(Updations)
- JDBC: Updatable ResultSet(Insertions)
- JDBC: Transaction in JDBC
- JDBC : Batch updations
- JDBC : AutoCommit Mode set to False
- JDBC : ResultSetMetaData interface
- JDBC : DatabaseMetaData interface
- JDBC:RowSet usage(JAVA 7 feature)
- JDBC : JDBC Drivers
hibernate
- Home
- hb: Mapping And Configuration Files In Hibernate
- hb : Inserting the records using hibernate
- hb : selecting the single record using hibernate
- hb : updating the single record using hibernate
- hb : deleting the single record using hibernate
- hb : Inserting records using hibernate Annotation
- hb : OneToOne XMl mapping (Unidirectional)
- hb : OneToOne mapping using Annotation (Unidirectional)
- hb : OneToOne XMl mapping (Bidirectional)
- hb : OneToOne mapping using Annotation (Bidirectional)
- hb : One to Many Xml Mapping
- hb : One to Many Using Annotation
- hb : Many to One Xml Mapping
- hb : Many to One to Annotation
- HB: Hibernate One-To-Many Using Annotation:
- hb : Many to Many Xml Mapping
- hb : Many to Many Using Annotation
- hb : Table Per Herarchy (TPH) using XML
- hb : Table Per Hierarchy using Annotation(TPH)
- hb : Table Per Class (TPC) using XMl
- hb : Table Per Class using Annotation(TPC)
- hb : Table Per Sub Class (TPS) using XML
- hb : Table Per Sub Class using Annotation(TPS)
- hb : Hibernate Query Language (HQL)
- hb : HQL NamedQueries Using XML
- hb : HQL NamedQueries Using Annotation
- hb: HCQL (Hibernate Criteria Query Language)
- hb : HCQL(Methods)
- hb : HCQL(Aggregate Functions)
- hb : HCQL(Projections)
- hb : Cache Implementation in Hibernate
- hb : Composite Key Implementation Using XML Mappin...
- hb : Composite Key Implementation Using Annotation...
- hb : Version maintenance in Hibernate
- hb : Hibernate Interview Questions
Interview Questions
Popular Posts
-
Lambda function to stop EC2 instance import boto3 client=boto3.client('ec2') def lambda_handler(event, context): re...
Subscribe to:
Posts (Atom)
No comments:
Post a Comment