You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Tim Pushor <ti...@crossthread.com> on 2001/09/12 09:10:37 UTC

Best practice?

I am wondering how people familiar with apache-asp would handle the
following issue:

I have a fill out form that POST's data to an asp page. That asp page will
perform some function, and report on what it found. In some cases, it won't
be able to perform the function for whatever reason. As I always test return
values for abnormal results, this page can also trigger an unexpected error
page.

So upon executing the asp page, I can output one of three different results:

1) Ok - heres the data
2) Nope - user error
3) unexpected error occurred

I would normally code 1) into the asp page in question. If condition 2) is
flagged in the code, can I conditionally <--#include the output for case 2?

As for 3: I want this page to send email to the site administrator as well
as give the user a descriptive message, so this functionality should be
available to all pages. I would probably put it in the global.asa (or a
PerlModule'd module). In this case, I cannot include an asp page.

I know these are basic questions, but I am just moving to apache-asp after a
long stint in cgi programming!

Thanks,
Tim


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Best practice?

Posted by Joshua Chamas <jo...@chamas.com>.
Tim Pushor wrote:
> 
> Thanks guys, you have pointed me in the right direction. Being a raw cgi
> programmer, I have developed methodology for doing things and is sometimes
> challenging to 'undo'.
> 
> I do have questions regarding using HTTP errors though:
> 
>  - Does IE display the error page that you designed, or a 'friendly error'?

Recent versions of IE have tended to display friendly errors, but
I believe this can be circumvented if you have a long enough error
message in bytes, which I read once, but I don't know how long that is.

>  - Can I pass information into the error page? Like error messages?
> 

You could have an ErrorDocument be an ASP script, but Apache will
call it only with special %ENV/ServerVariables data on normal 
errors like 500s.  If you wanted to have some custom error.inc
that you call for user defined errors, you could call it however
you like & pass in whatever args as in:

  $Response->Clear(); # clear preceding buffer
  $Server->Transfer('error.inc', @args);

But to get args into a normal ErrorDocument?  
I don't know what will happen if you defined the 
error document with a query string, like:
  $Response->ErrorDocument(500, 'error.asp?arg1=1&arg2=2')

??  Might not work.

--Josh

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Best practice?

Posted by Philip Mak <pm...@aaanime.net>.
On Wed, 12 Sep 2001, Tim Pushor wrote:

>  - Does IE display the error page that you designed, or a 'friendly error'?

IE will censor your error message if it is less than 512 bytes big, so if
you want to make sure it gets seen, pad it out to more than 512 bytes.


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Best practice?

Posted by Tim Pushor <ti...@crossthread.com>.
Thanks guys, you have pointed me in the right direction. Being a raw cgi
programmer, I have developed methodology for doing things and is sometimes
challenging to 'undo'.

I do have questions regarding using HTTP errors though:

 - Does IE display the error page that you designed, or a 'friendly error'?
 - Can I pass information into the error page? Like error messages?

Tim
----- Original Message -----
From: "Joshua Chamas" <jo...@chamas.com>
To: <jo...@ce.gatech.edu>
Cc: "Tim Pushor" <ti...@crossthread.com>
Sent: Wednesday, September 12, 2001 9:25 AM
Subject: Re: Best practice?


> John hit this right on, with the only thing to add
> that your "unexpected error" is a server error of code
> 500, which response page you can set with Apache's
> ErrorDocument config, or the $Response->ErrorDocument
> as John mentioned.
>
> --Josh
>
> "John D. Leonard II" wrote:
> >
> > Tim:
> >
> > Joshua can probably answer best, but I can offer a few broad
suggestions:
> >
> > > So upon executing the asp page, I can output one of three
> > > different results:
> > >
> > > 1) Ok - heres the data
> > > 2) Nope - user error
> > > 3) unexpected error occurred
> > >
> > > I would normally code 1) into the asp page in question. If condition
2) is
> > > flagged in the code, can I conditionally <--#include the output
> > > for case 2?
> >
> > I suggest that you get comfortable with the $Response->Include("file",
> > @args) syntax.  It allows you to think of include files as subroutines,
with
> > arguments in and return values out.  I have also found
> > $Response->TrapInclude to be very cool also.
> >
> > In this case, you can centralize all error processing, including sending
> > email, into a single ASP script called with a $Response->Include or
> > $Response->TrapInclude.
> >
> > > As for 3: I want this page to send email to the site administrator as
well
> > > as give the user a descriptive message, so this functionality should
be
> > > available to all pages. I would probably put it in the global.asa (or
a
> > > PerlModule'd module). In this case, I cannot include an asp page.
> >
> > Take a look at:
> >
> > $Server->Mail,  $Server->RegisterCleanUp and $Response->ErrorDocument.
> >
> > Getting used to the ASP model takes a while.  However, I have found the
> > transition pleasant and gradual, and once fully adopted, quite
productive!
> >
> > JL
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> > For additional commands, e-mail: asp-help@perl.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


RE: Best practice?

Posted by "John D. Leonard II" <jo...@ce.gatech.edu>.
Tim:

Joshua can probably answer best, but I can offer a few broad suggestions:

> So upon executing the asp page, I can output one of three
> different results:
>
> 1) Ok - heres the data
> 2) Nope - user error
> 3) unexpected error occurred
>
> I would normally code 1) into the asp page in question. If condition 2) is
> flagged in the code, can I conditionally <--#include the output
> for case 2?

I suggest that you get comfortable with the $Response->Include("file",
@args) syntax.  It allows you to think of include files as subroutines, with
arguments in and return values out.  I have also found
$Response->TrapInclude to be very cool also.

In this case, you can centralize all error processing, including sending
email, into a single ASP script called with a $Response->Include or
$Response->TrapInclude.

> As for 3: I want this page to send email to the site administrator as well
> as give the user a descriptive message, so this functionality should be
> available to all pages. I would probably put it in the global.asa (or a
> PerlModule'd module). In this case, I cannot include an asp page.

Take a look at:

$Server->Mail,  $Server->RegisterCleanUp and $Response->ErrorDocument.

Getting used to the ASP model takes a while.  However, I have found the
transition pleasant and gradual, and once fully adopted, quite productive!

JL


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org