Here at the coffee house, we pride ourselves on being a great place to relax. The Coffee House is the Java Ranch on the weekend. If you’ve spent a long three months on a cattle drive and you’re exhausted from bit shifting and saddle sores, or if you’re new to the Ranch and want to get started in a slow and friendly manner, we welcome you and urge you to sit down on our big comfy couches with a nice cup o’java.
We still talk about Java but we don’t have long intense discussions about pass by value or get hot and heavy about whether a pattern is really just a Strategy or Front Controller. We just gab about the real basics of some Java topic or other, just getting at what’s actually important without really doing any code. And taking time to sip our coffee and digest one or two of Curly’s famous baking powder scones.
Sid, the cowpoke who ranches that huge spread down south o’ Deadville, and Zeb, the sheriff, and a bunch of other hands from around the county were sittin’ around, sipping their coffee silently in true cowboy fashion and reading the comics. Lacey and Brenda were behind the counter, making a rucus with that new fangled frappulatte machine.
Sid put down his paper and said, “All right. I am going to admit it. I know how to write good solid Java code til the cows come home, and I often do. I write it good, and sometimes the city folks even say it’s elegant. But what the heck is this J2EE thing and why do people want it?”
A few of the other cowboys heard him and snickered. But when he stood up and said, “All right, then one of you explain it to me!” and shot a hole in the roof, they shut up and slunk down a little farther in their chairs.
Zeb snorted. “That’s pretty much the deal, Sid .Everybody talks about J2EE but nobody knows anything about it. You want I should give you the high points?”
“That’d be pretty neighborly of you,” replied Sid. “I love my Java ranch and I don’t want to have to sell out and move down to one of them little NETranches if I can stay and just bring in a little J2EE blood.”
“All righty. And you braggin’ no-account cowpokes can all listen up too,
since I can tell you don’t know nothin’ about 2EE neither.” There was silence
from the othe end of the room.
Zeb settled himself a little lower under his hat. “Sid, you remember that project you had the last few years where you had to write that Web application for buying saddles over the Internet?”
Sid winced. “I sure do.It was awful, it took forever, I don’t think I did a very good job, and I was darned lucky to get paid after they went bankrupt. I had to write all sorts of code to deal with making sure people’s credit cards didn’t get stolen from hackers. I had to make sure that all the info about the saddles and saddle bags the customers wanted got to the saddle store, since these guys get pretty mad if they order one of this Big Jim saddles but they don’t get the right saddle blankets to keep their butts from blistering right off.”
“Oh, and that ain’t all. I had a terrible time getting the program to run right during the Saddle Soap festival when everyone and their horse was ordering saddles. I had memory problems and CPUs grinding to a halt when more than a few cowboys were ordering at a time. It was downright humiliating.”
Zeb nodded, grinning. “You were lucky to get out alive. And think about this. What if all those cowboys in China and Utah and England had wanted to order saddles, too? Was your security system and your data integrity system good enough to handle that? We know your resource management system sure wasn’t!”
Sid winced. saying “Don’t rub it in, Zeb. Of course they weren’t good enough for that. But it’s hard to write a good secure online application; security is incredibly complicated. And making sure that the data integrity is there, so people’s orders go through together, and so if their horse trips over the power line halfway through the order and leaves them all paid up without the message ever getting to the saddle warehouse that they should ship out the order, well, that’s really hard. And then of course, yes, the third one, resource management to make sure none of them little objects were using memory they shouldn’t and to make sure there’s enough CPU power all the time, well, I admit, that’s just about impossible. And it took me five years and a whole bunch of other ranch hands to do the project.”
Zeb downed the rest of his coffee and got up for more. This explanation was usually about a one-cupper, but Sid had gone on about his project a little longer than usual. “That’s right,” Zeb said as he filled up his cup and added a lot more cinnamon and cocoa than you’d expect from such a grizzly old sheriff. “It’s really hard.”
Sid looked at him and boggled with frustration. “What the heck are you doin’ to me? I ask you to explain J2EE to me, and here you are, just makin’ me go over my failed projects and limitations in public!”
“Calm down,” chuckled Zeb. “It’s OK. You’re not supposed to be able to
do it. It is really hard to do security, and data integrity things like transactions,
and resource management. So wouldn’t it be nice if you could just buy some
software that could do it for you?”
Sid stared at him. “You’re not telling me....you are telling me. Is that what J2EE is, a program that takes care of all that really hard stuff?”
“You’re telling me that instead of going through hell in a handbasket for five years and losing all that money, I could have just gone out and bought a J2EE—a J2EE— ”
“Server,” Zeb supplied.
“A J2EE server, and I could just tell it, OK, you J2EE server, when this order starts, you make sure it’s a transaction so that everything that goes together stays together? And if the order gets interrupted, you just pretend it all never happened?”
“And you’re telling me I can write a little code for this J2EE server just saying, what, Make this little ol’ application secure? Like a big scary robust extensible scarecrow all around the edge of the cornfield of my application?” He had gotten up on the bar in his excitement and was walking around, waving his hands and splashing his coffee in his excitement.”
“And you are telling me,” Sid stopped for breath and stood up as straight as he could, “that I can just tell this J2EE server, hey you, manage my resources so my application doesn’t grind to a halt every time there’s a bunch of people who want to order saddles all at the same time?”
“You know the answer to that,” Zeb grinned. “Yep!”
Sid was already in a dead faint, though, slumped over Lacey and Brenda, and didn’t hear him.
"Just one more thing," said Sid. "How does it all work? Do I just write my normal program like I normally would and then say, Hiyo server, away?"
"Well, not quite," Zeb told him. "You usually use beans. Not like those
charcoal black hard thing Curly serves for dinner, but special little J2EE
pieces of code. It's still Java, you just write them according to a
few Enterprise JavaBean rules. That's the core part of your application.
Then you stick it next to your J2EE server, you put a kind of a to-do list
or address book deployment descriptor file in with it to help the server
figure out what to do with those beans, and it all runs. All the people ordering
saddles, for instance, get sent to the server first. The server says, say,
hey Bean42, you go do such and such. And when all the beans are done doing
their business, then the server stores the results in the database, or tells
the customer something."
"Just to be clear, most of the time you call this server thing a container. The server's what you ask your storekeeper for, but the container is what does all this management for the beans."
"Dang," said one of the scruffy lookin' cowboys in the back. "Sounds like this container thing is kind of like Ella down at the Massage Parlor. She's the one who manages what goes on, and you don't do anything with them young ladies if you don't talk to her."
"Well, Zeek," said Zeb, "I might not describe it that way but you're pretty much right."
"I would like to add, though, that there's actually two kind of Ellas
in this picture. You got your beans doing your core important business stuff
like calculations and making sure credit cards are good, and they've got
an Ella. But what about all this ruckus going back and forth across the Internet
from your customers, up to the beans? What about all the stuff you have to
do to show your customers pretty pictures and lists of your saddles and get
their orders all collected and sent to your beans to do their processing?
Well, you use a couple things called JSPs and servlets. JSPs are the pretty
up front pieces of code that mostly do HTML but a little Java too, and servlets
can do a little HTML but mostly they do some harder core stuff, either processing
them JSP requests or sending info on to the beans, or both. And just so they
don't feel left out, the JSPs and servlets have a container that takes care
of them too. Another Ella from the Massage Parlor."
"So you got a customer saying Send me that rawhide saddle, and that request
just goes to the Web server which is kind of dumb and just does simple things.
Kind of like Red who sits on the edge of town and says Hi, welcome to town,
the Massage Parlor is north and the coffee house is south. Then the web server
passes the request for the rawhide saddle to the web container, who does
all sorts of handling and managing, messing around with the JSPs and servlets.
Then for really hard core processing it goes, whoop, one more step on to
the EJB container, the beans get into the action, and then finally the order
gets sent, and a message comes out the same way it went in saying thank you
very much, we hope you enjoy your saddle."
One of the lame ol’ cowboys in back piped up. “But I heard J2EE was really hard. This sounds real easy. You sure you’re givin’ us the straight story?”
“Well, who’d you hear sayin’ that J2EE was hard?”
“Heard it from a weaselly little fellow who came through last week selling patent medicine. Said his name was William Door.”
“Yeah, well, we’ve seen him around these parts branding our cattle with his mark and doing all sorts of other stuff that woulda gotten a guy strung up twenty years ago. Now think about it. Why do you think Sid here fainted? Was he afeared of writing J2EE stuff or was he just so mad and amazed that he did stuff by hand, badly, that he coulda just bought? It’s cuz of the second one. Writing the stuff that J2EE does for you is one heck of a lot easier than hooking up your application to J2EE servers.”
“And yep, it’s true you need to write your online application a certain way to make sure your J2EE server can grab onto your application at the right points and give it security, data integrity, and resource management. Kinda like cuttin’ the right holes in your house for the windows at just the right spot, or settin’ you and your cowboys up just right so the cows head straight into the corral. But you know, ain’t nothin’ easy in life and you know that if you use your J2EE server, all those services are done right. All you gotta do is write good code to let it all happen.
“J2EE ain’t the only server, by the way, that can do these kind o’services. But think about this. You gotta buy your server from somebody. What if the server turns out bad? What if your storekeeper who’s selling you your J2EE server heads out to Alaska for the gold rush or just starts being a real nasty sort o’guy, you can go get yourself a whole nother J2EE server and it’ll work pretty much the same way. Ol’ Willam Door can’t say that.”
“You can get a bunch of servers that will do these things for you, but
if you’re the kind of cowboy that doesn’t want to be fenced in, you want a
At that point, the Sons of the Pioneers came in and invited us all to join
them in a rousing chorus of “Don’t Fence Me In,” and we cheered and
sang and waved our coffee cups around. And then we carried Sid back to his
house, left him with a few links to J2EE servers like WebLogic and SunOne,
and went home to sleep off the caffeine before dinner.
A few of the cowboys eventually tracked down Zeb, and he told them that
if they wanted to lasso a better handle on how to do J2EE, they should walk
down to the corral and see Simon "Lefty" Brown, check out the article he wrote
this month, or go to his Introduction to the Java 2 Platform, Enterprise Edition (J2EE)
article in the October 2002 newsletter.