Forum Moderators: coopster

Message Too Old, No Replies

parsing jsp as php

with talk of jsp

         

jatar_k

11:10 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I do get tired of the people in suits continuously asking "why PHP, why not JSP?". The Sysadmin and I finally decided to give them their wish.

always make backups before doing foolish things like this!

1.2.3.#!/usr/local/bin/perl
#
# Usage: rename perlexpr [files]

($regexp = shift @ARGV) ¦¦ die "Usage: rename perlexpr [filenames]\n";

if (!@ARGV) {
@ARGV = <STDIN>;
chomp(@ARGV);
}

foreach $_ (@ARGV) {
$old_name = $_;
eval $regexp;
die $@ if $@;
rename($old_name, $_) unless $old_name eq $_;
}

exit(0);

4.6.DirectoryIndex index.jsp
AddType application/x-httpd-php .jsp

7.et voila, they get their site in jsp

now stop bugging me ;)

killswitch

3:22 am on Apr 9, 2004 (gmt 0)

10+ Year Member



Too funny. Just wait until they say, "Wow the site is much faster now that it's JSP".

ergophobe

2:07 pm on Apr 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just wait until you move on and they hire a JSP programmer to take over the site!

PCInk

3:04 pm on Apr 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



And if there are errors in the programming or it is in beta test, you could have the .microsoft extension?

jatar_k

4:06 pm on Apr 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



we were tossing around the idea of rotating the extension

we thought of using a few variations

.pl .asp .jsp .php

just rotate through them. There were some other thoughts as well but they are inappropriate to post. ;)

It does beg the question, what's in an extension?

lorax

12:53 am on Apr 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ROFL - I'd laugh much harder if I knew what half that code meant! :)

>> what's in an extension

It does seem pretty arbitrary now doesn't it. We can pretty much map any file extension to what we want regardless of MIME TYPE. The only person who really knows what's going on is the Sys Admin.

mep00

9:55 am on Apr 11, 2004 (gmt 0)

10+ Year Member



lol

Goes to show how a little knowledge is a dangrous thing (i.e., the suits).

As a side note, I read that the W3C recommends not using extentions in URLs in order to be able to changes to how the page is generated without changing the URL.

ergophobe

3:40 pm on Apr 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I read that the W3C recommends not using extentions in URLs

And has done so for many years. This would make Jatar_k's solution so much easier.

Have the site set up so that it doesn't use extensions, BUT, it does use mod_rewrite to do two things:

1. it lops off any extension and, for the purposes of finding the file, throws it away.

2. it takes the extension and rewrites it as a GET parameter 'ext'.

3. all inernal urls on the site are constructed by putting in the
$url . "." . $_GET['ext']

Now everyone gets a site with their favorite technology.

1. For execs who have heard about the W3C, they visit the site as it designed :

h**p://domain.com/page

They are impressed. Wow! No extensions. These guys know what they're doing.

2. For execs who believe that any cutting edge site will use JSP, Jatar_K says, "Oh we already have a JSP version of the site" and tells them to visit

h**p://domain.com/page.jsp.

mod_rewrite lops off the "jsp", adds it to every internal URI and serves up the page. Once again, the execs are impressed. Wow! We have a JSP site! These guys are good.

3. The execs ask "What about XML? Isn't that replacing HTML? Shouldn't we have some somewhere on our site?" Jatar_K responds: "Oh, everything is already done with xml. We have an alternative xml site for 'power users'. Just go to h**://domain.com/page.xml". Now the execs are really happy because, one the programmers they have are really good and two, they, the execs themselves are 'power users' because they are now visiting the xml site, not the regular old JSP site that the ignoramuses below them use. Give the programmers a raise.

4. The execs keep hearing that there is this RSS thing and that it's somehow related to web pages or something. They're not really sure, but they're pretty certain that it's something you can see in a browser if your programmers are good and up on the latest technologies. At the 4:00pm meeting on Friday, one of them who wants to wow everyone with his technical knowledge says: "Should we have some of that RSS stuff on our site." Jatar_K takes on his most pensive look and after about 15 seconds reflection says, "Well, it's really a technology that's only appropriate for the *most* tech-savy executives, so I've been skeptical of implementing it here. I'll see what I can do over the weekend." Over the weekend, Jatar_K watches a few movies, gets together with friends. Doesn't think about work for one second except to do two things. First, he does not shave all weekend and second he goes out and drinks far more than is good for him, especially on Sunday night. He shows up on Monday morning, late, unshaven and hung over. He's pale, tired and red-eyed. He has either been partying all weekend or staring at a computer screen without rest or respite for every minute since the 4:00pm Friday meeting. The execs aren't sure which until he announces, "Yeah I put together an RSS site this weekend. No big deal. Just go to h**p://domain.com/page.rss".

The execs are beaming. When Jatar_K leaves the room, one of them asks the others, "How much are we paying that guy?"

Tom

jatar_k

5:25 pm on Apr 11, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



rofl, nice

to be honest, that was the original plan almost verbatim.

It will just take a little more time to implement. :)

coopster

11:13 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



LOL. You guys need some more work.

Don't forget to budget for the high-end servers required to process all the new code.