tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Bremford" <mi...@paperx.com>
Subject RE: backwards compatibility?
Date Thu, 27 Jul 2000 14:52:24 GMT
Hi Russell


I think we have the same problem - some .jhtml pages that were written ages
ago, but that don't work with tomcat. (I'm no java whiz, but I think that's
what you're talking about - the files with <servlet> tags in them).

Although I'm hoping someone will add support for them to allow all those
still running Apache/JServ to migrate (hint, hint), in the meantime I've
written a wee script to convert .jhtml pages to .jsp's. The catch - it's
written in PERL!!! (thunder, lightening, reader recoils in horror). I've
attached it below if it's of help to anyone.

Just to repeat - if anyone's listening that can make a difference, I know
it's not part of the spec anymore, but adding a handler for .jhtml files
would ease the migration process from Apache/Jserv for many.

Here's the script. Note large number of indecipherable regular expressions,
and the fact that it's only 30 lines long. You gotta love Perl. :-)


Cheers.... Mike

------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------


#!/usr/bin/perl
#
# Usage: jhtml2jsp < infile > outfile
#
# Convert .jhtml files with <servlet> tags into jsps with <jsp:include>
tags.
#
# mike@big.faceless.org - May 2000
#

my @params = ();
my $servlet="";
my $eol="\n";

while (<>) {
    $eol="\r\n" if (/\r/);
    chomp;
    s/\r//;
    if (/(.*)<servlet\s+code=["']?(.*?)["']?\s*>/i) {
        $servlet="$1<jsp:include page=\"$2"."?";
        print STDERR "Servlet \"$2\"\n";
    }
    if ($servlet) {
        while (/<param/i) {
            s/<param\s+name=["']?(.*?)["']?\s+value=["']?(.*?)["']?\s*>//i;
            print STDERR "--> Param \"$1\"=\"$2\"\n";
            ($key=$1) =~ s/([^a-zA-Z0-9_.-])/uc
sprintf("%%%02x",ord($1))/eg;
            ($val=$2) =~ s/([^a-zA-Z0-9_.-])/uc
sprintf("%%%02x",ord($1))/eg;
            push (@params, "$key=$val");
        }
        if (/<\/servlet\s*>(.*)/i) {
            print STDERR "End Servlet\n";
            push (@out, $servlet . join("&", @params) . "\" flush=\"true\"
/>$1");
            @params=();
            $servlet = "";
        }
    } else {
        push (@out, $_);
    }
}
print join($eol, @out).$eol;


------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------

-----Original Message-----
From: Russell Gold [mailto:russgold@acm.org]
Sent: 27 July 2000 14:52
To: tomcat-user@jakarta.apache.org
Subject: backwards compatibility?


Is there any way to get Tomcat to recognize JSPs written to version
0.92?  In particular, I am looking for support for the NCSA-style
server-side includes, which were replaced in the 1.0 spec with the include
directive.



Mime
View raw message