After completing this How-To
you should be able to:
Know about handling
ESI exceptions using esi:try | attempt | except tags.
Introduction
Edge
Side Includes (ESI) is an open specification for a simple markup language that
enables dynamic page fragmentation, caching and assembly. It improves the performance
and reduces the cost of dynamic content creation. ESI provides exception handling
mechanism using the esi:try | attempt | except tags, to catch ESI exceptions and
suitably handle them.
Pre-requisites for running
the example
You will need the following to run this
example -
Oracle Application Server (9.0.3 or above). This
can be downloaded from here
Oracle JDeveloper (9.0.3 or above). This can be downloaded from here.
This is optional and required only if you wish to deploy from JDeveloper.
Description
ESI exceptions are generated by the ESI processor, while processing the ESI instructions.
For example, while processing <esi:include> if the included source generates
server exception returning HTTP 5xx status code, then the ESI processor throws
httpservererror exception. Few of the exceptions, that ESI can handle
are :-
httpclienterror
- This error occurs, when the origin server returns HTTP 4XX status code like
(resource not found, malformed HTTP request, or unauthorized access.
httpservererror
- This error occurs when the origin server returns HTTP 5XX status code, a server
error
noconnection - This error occurs when the cache server
is unable to connect to the origin server serving the fragment
nestingtoodeep
- This error occurs when the fragment include depth has exceeded the maximum include
depth.
originserverbusy - This error occurs when the origin
server is busy and cannot accept new requests now.
networktimeout
- This error occurs when the request to the origin server has timed out in the
network connection.
The example depicts the
employee information system. It displays profiles of the employees using the <esi:include>
tag. Unavailable profiles of the employee are handled using the esi:try | attempt
| except tag. In the following code snippet, the httpclienterror
(404 - file not found) is handled by the httpclient.html
The complete source code for this sample
is available here. This section discusses the instruction
to run the sample application
Step
1
Unjar esitry.jar
using Winzip, or using the following command:
> jar
xvf esitry.jar
This creates a directory esitry.
Step 2
If you are using JDeveloper then, follow these steps
Open
Oracle9i JDeveloper and use File/Open option to select the
esitry.jws from the esitry directory.
Next,
select Project/Make esitry.jpr from main menu.
Create
an application server connection
Go to Connections -> Application
Server Connection. Right Click and click New connection..
In step 1, enter
connection name and select Oracle9i Application Server
In step 2, enter
user name and password
In step 3, enter Enterprise Manager's host name,
port number and Remote Oracle AS home directory(required only if deployed on remote
machine).
In step 4, click Next and Test the connection. Click Finish
button.
Now, Right click esitry.deploy
and select Deploy to <connection name>, to the application server connection,
which you have created in the previous step.
Step
3
To deploy the application using EM. follow
the steps.
Go to EM web site -> default oc4j
home.,
Choose Deploy EAR file
Enter J2EE Application name, Click
the Browse button and choose esitry.ear from <SAMPLE_HOME>/deploy/esitry.ear
Enter
the Application name as jesiinclude and click next
Enter URL mapping as
/esitry and click Finish
Click Deploy to deploy the application.
Running the Sample
Access
the page on the browser, using the following URL
http://<host_name>:<port>/esitry/empinfo.html
where, <host_name> is the machine on which Web
Cache is installed and <port> is the port on which Web Cache listener is
running.
For Example, http://incq185b.idc.oracle.com:7777/esitry/empinfo.html