logo

Response

« Return to the main article

You are viewing this page out of context. To see it in the context it is intended please click here.

About This Page

Reply posted by Chris King on Sat 29 Sep 2001 in response to Complete control when printing HTML from an agent

Not limited to HTML, also Excel, GIF, XML, etc.

You can also use this technique to create other kinds or responses besides
HTML. The important thing to remember is that you need to change the
Content-Type also known as MIME type. For example, this line:


Print "Content-Type:text/html"


would change to this for Excel:


Print "Content-Type:application/vnd.ms-excel"


Then instead of writing out HTML, you can write out comma seperated text and
Excel will launch and convert it. It's a really slick way to exporting to
Excel from the web; One that I stole from my credit card company. They're not
using Notes, but the principle is the same.


If you want to get really complicated, you could have your agent write out a
binary transfer to the browser. This is how you would use an agent to create a
picture. You could use this to search and return scanned documents from
another system (although there would probably be an easier way). I've only
done this in Java and can't find the code anymore. But, you just read in a
binary file (in my case from our imaging system) and print it out to the
browser in binary form. Of course, the Content-Type is still set with text, as
follows:


Print "Content-Type:image/gif"


Most web servers have a configuration file called mime.types or mime.properties
or mime.cfg or mime.ini or something like that. If you look at that file you
can tell what your options are. Most are obvious and have the program name in
the description.