You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "Alexei V. Alexandrov" <av...@elcomsoft.com> on 2001/11/30 12:25:37 UTC

Generating dynamic content.

Hello everyone,

Maybe it is not clear in the subject but let me explain my question. Here is
what i want to do:
The browser requests a page that does not actually exist and should be
outputed directly from a db or other kind of storage. The browser requests a
page for example (/article/2001/11/30/0001.html) then i should handle this
request to parse the uri and out put the content. In mod_perl it`s clear to
me how to do this, but how can i do it in EmbperlObject. Should i make an
empty directory /article with an OBJECT_BASE file in it which parses the uri
and outputs the dynamic content. Am i right? Are there any better solutions
to achieve what i want?

P.S.: Sorry for my poor written english :)

---
  Best regards,
  Alexei V. Alexandrov
  ElcomSoft Co. Ltd.
  www.elcomsoft.com


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


Re: Generating dynamic content.

Posted by Gerald Richter <ri...@ecos.de>.
> > page for example (/article/2001/11/30/0001.html) then i should handle
this
>...
> Answering myself :) I have found a way to handle such situations.
> The FALLBACK_OBJECT is called when server encounters 404 error code file
not
> found.
> So if i set ErrorDocument 404 to /path/to/err-404.html Embperl will handle
> it and look also for an OBJECT_BASE file.
> In the base.epl handling 404 can be done in this way:
>

Another possibilty is to use PATH_INFO. Create a document called article.htm
and then request it with

/path/to/article.htm/2001/11/30/0001

article.htm looks like:

[- @article = split ('/', $req_rec -> path_info) -]
Year: [+ $article[0] +] Month: [+ $article[1] +] Day: [+ $article[2] +]
Article: [+ $article[3] +]

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




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


Re: Generating dynamic content.

Posted by "Alexei V. Alexandrov" <av...@elcomsoft.com>.
> Hello everyone,
>
> Maybe it is not clear in the subject but let me explain my question. Here
is
> what i want to do:
> The browser requests a page that does not actually exist and should be
> outputed directly from a db or other kind of storage. The browser requests
a
> page for example (/article/2001/11/30/0001.html) then i should handle this
> request to parse the uri and out put the content. In mod_perl it`s clear
to
> me how to do this, but how can i do it in EmbperlObject. Should i make an
> empty directory /article with an OBJECT_BASE file in it which parses the
uri
> and outputs the dynamic content. Am i right? Are there any better
solutions
> to achieve what i want?

Answering myself :) I have found a way to handle such situations.
The FALLBACK_OBJECT is called when server encounters 404 error code file not
found.
So if i set ErrorDocument 404 to /path/to/err-404.html Embperl will handle
it and look also for an OBJECT_BASE file.
In the base.epl handling 404 can be done in this way:

[-
 if ($req_rec->prev->status == 404) {
  if ($req_rec->prev->uri =~
/\/embperl\/([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/([0-9]+)\.html/) {
   %fdat = $req_rec->prev->args();
   $req_rec->status(200);
   $http_headers_out{'Content-Type'} = "text/plain";
   print OUT "Year: $1\nMonth: $2\nDay: $3\nArticle: $4\n-----[
\%fdat ]-----\n";
   while (my($k,$v) = each %fdat) {
    print OUT $k . " = " . $v . "\n";
   }
   exit;
  } else {
    Execute(.......);
  }
 }
-]

That handles everything in a manner i wanted. Thanks.


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