Simple ASP Application
Download the authoritative guide: Data Center Guide: Optimizing Your Data Center Strategy
Download the authoritative guide: Cloud Computing: Using the Cloud for Competitive Advantageby Bob Dombroski
This application was my first endeavor into the world of ASP. It evolved from a VB program I had written to handle directory browsing for a site running Sambar 4-1. The application itself was designed to handle a problem sharing reports coming off a mainframe. The only solution prior to this application was to wait a few hours(or days) to get the report to paper and hand deliver it(even if you only needed 10 pages out of 100 page report).This application was my first endeavor into the world of ASP. It evolved from a VB program I had written to handle directory browsing for a site running Sambar 4-1. The application itself was designed to handle a problem sharing reports coming off a mainframe...
The application design: this application assumes the report files have a .txt extension
- Get the report from the mainframe to the web site(in a text format). This is easy using FTP. If you need more info on this aspect email me and I will try to help you set up the FTP server.
- Allow browsing of the received report files.
- View the report files. Here we will allow options to view an enhanced report, or a standard report. The enhanced report does stuff like turns negative numbers to red and adds a green-bar or grey-bar background. The standard report is jst a link to the text file.
' We use the server object called mappath which gives the physical path to a virtual directory(or file). This assumes you have a virtual directory called REPORTS.
FTP_VIRTUAL_PATH = "/REPORTS"
FTP_PATH = SERVER.MAPPATH(FTP_VIRTUAL_PATH)
Note: The example here at Swynk.com has some added code since I dont have a reports virtual directory. The report files are in the same directory as this file. I had to map a path from the original page and chop off the file name to get a physical path to this directory.
SET O_FSO = CREATEOBJECT("SCRIPTING.FILESYSTEMOBJECT")
SET O_FOLDER = O_FSO.GETFOLDER(FTP_PATH)
SET O_FILES_IN_FOLDER = O_FOLDER.FILES
' These three lines of code obtain a collection of files within the FTP_PATH(folder).
NOTE: In the ftp job I created for the transfers, I preceed the file name with a 3 position userid to easily see who uploaded each file. This makes finding a specific report easier. The guts of this page shows a table with 4 columns. The first shows the persons id who uploaded the file, the second provides a link to the enhanced report(an ASP page), the third has a direct link to the report itself and the last column shows file information(creation date and size). The end result we want should look something like this:
|KIM||4th Quarter Summary||4th Quarter Summary||09/04/98 Size : 1,328|
|GAR||Q4 Dept Report||Q4 Dept Report||09/17/98 Size : 5,245|
The Code behind it:
First set up the table with headings:
<TABLE BORDER = "1" WIDTH = "100%">
<TD WIDTH="25%"><P ALIGN = "CENTER">UPLOADED BY</TD>
<TD WIDTH="25%"><P ALIGN = "CENTER">ENHANCED REPORT</TD>
<TD WIDTH="25%"><P ALIGN = "CENTER">REPORT</TD>
<TD WIDTH="25%"><P ALIGN = "CENTER">FILE INFO</TD>
Now for the Script:
<% FOR EACH OBJFILEITEM IN O_FILES_IN_FOLDER
USER = MID (OBJFILEITEM.NAME, 1, 3) ' Get the user id(the first 3 chars in the file name)
FILE_NAME = MID (OBJFILEITEM.NAME, 4, (LEN(OBJFILEITEM.NAME) - 1)) %> 'Get the file name minus the user id
<TD WIDTH = "25%"><P ALIGN = "CENTER"><%=USER%></TD> 'Note the<% =USER%> is a short cut it could also be coded as <% RESPONSE.WRITE( USER ) %>
<TD WIDTH = "25%"><P ALIGN = "CENTER"><A HREF = "ENHANCED.ASP?E_FILE = " <%=OBJFILEITEM.NAME%>"><%=FILE_NAME%></A><TD>
Here we create a link to the Enhanced.asp page passing it the variable E_FILE with the file name the user is requesting
<TD WIDTH = "25%"><P ALIGN = "CENTER"><A HREF = "
<% VIRTUAL_FILE = FTP_VIRTUAL_PATH + "/" + OBJFILEITEM.NAME
RESPONSE.WRITE VIRTUAL_FILE %> "> <%= FILE_NAME %> </A><TD> This creates a link directly to the report file.
<TD WIDTH = "25%"><P ALIGN = "CENTER"><%RESPONSE.WRITE OBJFILEITEM.DATECREATED & " SIZE " & OBJFILEITEM.SIZE%></TD> Display the date the file was created and the size of the file
<% NEXT %>
One of the things I am always trying to find time for is to create an administrative page which would allow for directory clean up of the reports directory. When I find the time to write it, I will post the code. If anyone has any improvements to suggest please email me and I will post your suggestions with full credit to you.
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...