Plands.com Logo  Business Internet Services 
Main Menu
Home
Planetary CRM
  Benefits
  Features
  Demo
E-Mail Services
  E-mail Hosting
  Newsletters
  Discussion Lists
Web Hosting
Server Co-location
and Administration
Web Applications
Technical Support
Contact Us
DXP Samples
 
DxpHome  ||   Samples  ||   Details  ||   Docs  ||   Trees  ||   xml-xsl  ||   Links
// ReadBytes.java

ReadBytes is a fast way to insert a file into the OutputStream. This can be used to insert files that are used as common headers and footers in html pages and also to insert files multiple times on the same page without having to re-read them.

The ReadBytes and Bytes tags are similar to their text oriented counterpart, ReadFile and Rp. Reading and writing bytes directly is faster because bytes are not converted into chars and Strings. On the other hand, runtime text values can't be inserted into bytes read by the ReadBytes tag.

Here is a simple example:

<dxp:ReadBytes filename="siteheader.txt"/>
  ... 
<dxp:ReadBytes filename="techsupport.txt" store="support"/>
  ... 
  Contact tech support at:
<dxp:Bytes name="support"/>
  ... 
  And if you still have trouble call:
<dxp:Bytes name="support"/>
  ...
<dxp:ReadBytes filename="sitefooter.txt"/>

You can also specify a filename by parameter

<dxp:ReadBytes fileparam="filename"/>

Important difference from URL references:<br /> All filename attributes and posted filename parameters must be specified relative to the docroot without any "../" or "..\" substrings in the filename. In other words, if you specify filename="../myfile.txt" this will throw and Exception. This is used to keep users from inserting files that are outside the docroot specified in the dxpservlet.properties for the virtual host in question.

The docroot is normally set to something like /home/hostname/htdocs. If you want insert the file /home/hostname/htdocs/header.txt you would specify filename="header.txt" and the tag would prepend the docroot to the value.

If you are using this tag in a subdir like /home/hostname/htdocs/products and you want to include /home/hostname/htdocs/header.txt you would just specifiy filename="header.txt" rather than "../header.txt". The tag will prepend the docroot to header.txt

If you want to include a file inside the products subdir you would specify filename="products/myfile.txt". Again the tag will prepend the docroot.


@author Mark Ashworth
@version 0.2, 2002-04-02

Return to Index

Note: We have tried to test all of the code examples but they may contain errors. Any questions, comments, suggestions, or problems should be sent to info@plands.com.