Help > Web Development > Object Reference > Code Samples > ASP > Using the ISYSImageCache
<a name="kanchor591"></a>Using the ISYSImageCache
Demonstrates using the ISYSImageCache object from your web site.

Global.asa
<% Sub Application_OnStart ' Prepare the ISYSASP object, store it in application scope Set Application("ISYS") = Server.CreateObject("ISYS.ISYSAsp") ' Prepare the ISYSImageCache object, store it in application scope Set Application("ISYSImageCache") = Server.CreateObject("ISYS.ISYSImageCache") End Sub %>

Document View

<% ' Assumes that the search has been executed and reloaded, and the ' Document variable was been set with the document we are about to open. ' Get the DocumentDisplay object from the document we wish to display Set Display = Document.Display ' Setup hit coloring Display.Option(doBeforeHitByTerm) = "<span style=""color: %FGCOLOR%; background-color: %BGCOLOR%"">" Display.Option(doBeforeFirstHitByTerm) = Display.Option(doBeforeHitByTerm) Display.Option(doAfterHitByTerm) = "</span>" Display.Option(doAfterLastHitByTerm) = Display.Option(doAfterHitByTerm) ' Prepare the image cache, Results and Doc are passed in on the query string Application("ISYSImageCache").Prepare Document, Array(Request("Results"), Request("Doc")) ' Setup the embedded resource url Display.Option(doImageUrl) = "resource.asp?Results=" & Request("Results") & _ "&Doc=" & Request("Doc") & _ "&Resource=" ' Stream the output to the Response object Display.Stream Response %>

Resource.asp

<% ' This page fetches the embedded image for RichHTML pages ' Prepare the document's key, same as the one used in Prepare Key = Array(Request("Results"), Request("Doc")) ' Get the image data ImageData = Application("ISYSImageCache").Fetch (Key, Request("resource")) ' Clear the output stream Response.Clear ' Set the content type ImageType = LCase(Right(Request("resource"), 3)) If ImageType = "jpg" Then Response.ContentType = "image/jpeg" ElseIf ImageType = "gif" Then Response.ContentType = "image/gif" Else Response.ContentType = "image/" + ImageType End If ' Send the image data Response.BinaryWrite ImageData ' Finalize the request Response.End %>