[AWS] Some questions
David Marceau
davidmarceau@sympatico.ca
Thu, 31 Oct 2002 12:38:34 -0500
Francisco Sanchez wrote:
> Here is my code:
> function HW_CB (Request : in AWS.Status.Data)
> return AWS.Response.Data is
> begin
> return AWS.Response.Build ("text/html",
>
There are two alternatives for returning your response:
1)return a response string which represent the frameset as you've done
which seems to be buggy still.
Here is a really simple html string that works and displays correctly.
return Response.Build
(Content_Type => "text/html",
Message_Body =>
"<p>Hello<p>"
& URI & " was requested however I don't have it. Sorry :("
);
************What I think you really want to serve up
follows:*****************
2)return a response based on a file which is what I think you want. You
may use your original html file or generate one on-the-fly.
I am going to assume you want to generate an html file on-the-fly.
I am going to assume you know what you're doing with your framesets and
that your html files exist.
I am going to assume your original html masterfile is called
originalmaster.html
I am going to assume you aws generated html masterfile is called
awsgeneratedmaster.html
Create a separate service to create you aws generated html master file:
i.e. create_aws_generated_html_master_file is
--declare stuff for your output file handle
your_aws_master_html_file : ada.text_io.file_type;
begin
--open your output file
ada.text_io.create
(
file => your_aws_master_html_file
, Mode => ada.text_io.out_file
, name => "awsgeneratedmaster.html"
);
-- For debugging purposes, why don't you place new_lines after every
html string you in your ada code.
ada.text_io.put(your_aws_master_html_file, "<html>");
ada.text_io.new_line(your_aws_master_html_file);
-- Notice I didn't use put_line because is adds the use of new_line
after every string which isn't exactly what you want.
-- You have more control this way.
-- ditto for the rest of your html source including the frameset
stuff...
ada.text_io.close(file => your_aws_master_html_file);
end create_aws_generated_html_master_file;
In that manner the ada source outputs exactly like the original source
html file. In fact that is the point. To ensure your ada source
duplicates the exact structure you had in your original skeleton html
file. If all is done properly if you diff between your adagenerated
html file and your original html file, there should be no difference.
Then you replace your return response with this line in your code
return Response.File (Content_Type => "text/html",
Filename =>
"awsgeneratedmaster.html");
Notice the content type parameter says text/html. This is in fact the
mime type you will find among all the different types accepted in your
web browser.
You might also want to return other types of files with different mime
types.
Say you wanted to serve up mp3's:
return Response.File (Content_Type => "audio/mpeg3",
Filename =>
"13_réjouissance_12.mp3");
or you wanted to serve up flashes:
return Response.File (Content_Type => "application/x-shockwave-flash",
Filename => "projetlemoyne.swf");
or you wanted to serve up adobe acrobat pdf files you created:
return Response.File (Content_Type => "application/pdf",
Filename => "davidmarceauEn.pdf");
To see all the other supported mime types you may want to serve up,
check out the supported list in your web browser plugin list.
To summarize
------------
Although just sending one string most of the time via response.build
service is ok, I would recommend:
1)to generate a file first
2)return the file as a response
I'm no aws expert but I would say this is a good rule of thumb to
facilitate debugging.
Feel free to contradict me :) I'm all ears :)