Using an Error Page


To display a helpful message in the event of an error, use JFile's ErrorURL parameter. The ErrorURL parameter specifies the URL of a page to display when an error occurs. When you set the ErrorURL parameter, JFile will add an error code to the URL's query string. For example, if ErrorURL is set to http://localhost/jfilescripts/errorpage.asp, JFile will send the query string http://localhost/jfilescripts/errorpage.asp?jfile_errorcode=number.

ErrorUrl Limitation
JFile's ErrorURL parameter does not work with file downloads.
Recursive Directory Upload

Exercise: Creating an Error Page

  1. If you created the physical and virtual JFileScripts directories in a previous lesson, go to Step 4. If you did not create the directories, go to Step 2.

  2. Create a directory called JFileScripts.

  3. Create a virtual directory called JFileScripts and map it to the physical JFileScripts you created in Step 2:

    1. Open the Internet Information Services (IIS) explorer.
    2. Right-click Default Web Site.
    3. Select New -> Virtual Directory.
    4. For Alias, enter JFileScripts.
    5. Browse to the JFileScripts directory you created in step 1.
    6. Check "Read" and "Run scripts."
    7. Click "Finish."

  4. Copy filetransfer.jar (for Netscape) and/or filetransfer.cab (for Internet Explorer) to the directory JFileScripts. These files are in JFile's installation directory (by default, C:\Program Files\SoftArtisans\JFile).

  5. Copy formresp.asp to the directory JFileScripts. Formresp.asp is a server-side upload processing script that you will find in JFile's Samples\Upload\Simple directory (installed by default at C:\Program Files\SoftArtisans\JFile). Formresp.asp uses SoftArtisans FileUp to process the upload.

  6. Create an ASP script containing the following line. Name it errorpage.asp and save it in the directory JFileScripts.
    SoftArtisans JFile error <% =Request.QueryString("jfile_errorcode") %> occurred.
  7. Create an HTML script containing the following lines. Name the file errorupload.htm and save it in the directory JFileScripts.
    <APPLET codebase="/JFileScripts" code="softartisans.filetransfer.UploadClient.class" 
    height="0" width="0" mayscript archive="filetransfer.jar" name="fileupload">
    	
    	<!-- The Cabbase parameter specifies the cab file containing the applet. -->
    	<PARAM name="cabbase" value="filetransfer.cab">
    	
    	<!-- The ErrorURL parameter contains the URL of a file to open when an error occurs. -->
    	<PARAM name="ErrorURL" value="http://localhost/jfilescripts/errorpage.asp">
    
    	<!-- The PostURL parameter specifies the URL to which the file will be posted. -->
    	<PARAM name="PostURL" value="http://localhost/jfilescripts/formresp.asp">
    	
    	<!-- The FileName# parameter specifies a file to transfer.  To see your error page, enter an 
    	invalid file name. -->
    	<PARAM name="FileName1" value="c:\invalidname.ext">
    			
    </APPLET>
  8. To run the script, open the browser, and enter the URL http://localhost/jfilescripts/errorupload.htm.

Understanding the Script

Errorpage.asp

When you assign a URL to the ErrorURL parameter (as you do in errorupload.htm), JFile will add an error code to the URL's query string. In our case, the ErrorURL with JFile's error code would be,

http://localhost/jfilescripts/errorpage.asp?jfile_errorcode=number

Errorpage.asp retrieves JFile's error code from the request's query string and displays an error message containing the code, as follows,

SoftArtisans JFile error <%=Request.QueryString("jfile_errorcode")%> occurred.

The following table lists JFile's error codes and their definitions.

Name Value Description
Cancel_Error 100 The user hit the cancel button or closed the status window during a transfer.
General_Receive_Error 200 A failure occurred while receiving a response from the server. The connection with server may have been reset.
General_Send_Error 300 Error occurred while sending the request to the server. The connection with the server may have been broken. There may be a malfunctioning proxy server preventing a large transfer. There may be insufficient privileges on the remote system.
Https_Socket_Not_Supported_Error 301 SSL is currently not supported when using Sockets.
File_Not_Found_Error 302 There are two possible causes: 1) the PostURL is invalid or doesn't exist, or 2) the local preset filename does not exist.
Enable_Permissions_Error 303 This occurs only with Netscape 4.7x, if user has not been granted the required permissions.
No_Files_To_Send_Error 304 No files are set to be uploaded to the server. This may occur if the value of AllowFiles or RestrictFiles is too restrictive.
File_Verification_Error 305 The MD5 hash key generated by the DownloadClient does not match the key sent from the server.
Version_Expired_Error 400 The trial version has expired.
Resume_Init_Error 500 A file system error occured when preparing a resumed file transfer request. This is usually caused by insufficient access rights to JFile's temp directory for resumable uploads (JFileResumeDir).
Successful_With_Download_Error 501 The download completed, but errors occurred during the HTTP download process. Some files were downloaded with errors.
Successful_With_Move_Error 502 The HTTP transfer completed successfully but JFile was unable to save the file to the requested destination. This is usually caused by insufficient access rights or limited disk space.
Errorupload.htm

Copyright © 2000-2003 SoftArtisans, Inc. All rights reserved.