Application • 52:07
Mac OS X is a great platform for prototyping, developing, and deploying your next Internet application. This session will cover in great detail the powerful technologies incorporated into the platform for website building. We cover PHP, mySQL, Tomcat, Apache, and additional open source favorites that are built in to every copy of Mac OS X, as well as others that you can readily install to create compelling websites.
Speakers: John Montbriand, Ted Jucevic, Daryl Lee
Unlisted on Apple Developer site
Transcript
This transcript was generated using Whisper, it may have transcription errors.
Thank you for coming to our session. My name is John Montbriand. I work in Apple Developer Technical Support. Part of what I do is I take care of the sample code collections and the technical note and technical Q&A collections. And of course, doing that, I have plenty of opportunity to work with web servers and prototyping stuff on the web, and that's what I'm here to talk to you about today.
So first of all, let's set the context for what we're talking about here today. We're talking about building your website on Mac OS X. So what does that mean? A website has many components, and you look at your website through web browsers. So we're going to talk in this talk about all the different components of a website.
We're going to talk about all the parts that make up a website, which includes server software, scripting languages, HTTP software, and databases. Now, when you're developing a website, what are the things that you do? The first thing that you do is, of course, you upload it to a server, and then you look at the website with your browser. Now, that whole activity, there's only one thing that takes a lot of time there, and And that's the network, because you have to make your pages on your machine, upload them to a server, and then view them with your browser. So the feedback loop you have going on there, it's really slow, and it can take a lot of time to develop the website that you're working on. So what I'm going to talk to you about today is putting this all onto one computer and getting your computer configured so you can preview your website and you can edit your website so you have a really close feedback loop when you're working on your website. And in going through that, we're going to talk about the server software, setting up that to bend HTTP pages. Of course, on your machine you have Apache built in. And I'm going to show you how to configure that to do things like PHP and server side includes and it's very easy to do. The next thing I'm going to talk about is database software. Where you can get that, how you can download it and install it. There's some really easy to install packages available on the Internet that you can use. We'll be showing you where to get those and how to install them. The next thing we're going to talk about is scripting languages. There's a whole bunch of really good scripting languages installed on Mac OS X. You can extend those languages, you can add packages, and you can install extra ones as well, and we'll be showing you where to get those. Then I have two special guests coming in to talk to you about server-side Java and how you can install that on your machine and do your prototyping locally. Now, of course, I should point out that none of this requires Mac OS X server. You can do all of this with your client version of Mac OS X. All the things that I'm showing here today, you can do these on Panther, Jaguar, and I think all the way back to 10.0 as far as I know.
So let's start talking about HTTP server software. We have Apache installed on Mac OS X. And of course, on Mac OS X server, it's also installed. It's installed with a few more options already set up for you. And of course, there's some really nice configuration software available on 10 server. But we're not talking about that today. We're just talking about the client version and how you can turn that on. Now basically, if you wanna turn on Apache, all you do is you go into the server settings or the sharing settings and you turn it on using a checkbox. And for those of you who are more savvy on the command line, you can use that to turn it on and off using the Apache control statement shown there.
Now, I'm going to show today how to set up three different websites. The first two are going to be in your sites folder inside of your home directory. And the first site I'm going to show, I'm going to show how to set this up. This is the basic kind of layout of how we access these. We're going to show how to access websites through your local host address and then through URLs with the tilde username. And then I'm going to call one folder site one and one folder site two. And we access all this through the local host URL with the tilde username. So the first thing we need to keep in mind is all the configuration globally on your system is stored in the HTTP configuration file. And I'm going to show you how to set that up to turn on PHP. But we don't actually have to do anything to that file beyond turning on different options. You can turn on PHP. You can turn on mod_perl if you want. And those things are all there. And you just need to turn them on. So I'll show you how to do that. Now, for each one of the sites we're going to do, there's different URLs that you access those through. There's going to be tilde, username, site one, tilde, username, site two. And these are all referring to folders that are installed in your user sites folder.
Now the configuration for those specific folders are stored inside of htaccess files. And this is a normal thing to do if you've developed on any web servers and you want a prototype. You'd use the htaccess files, and you just place those on your servers with your various options, like turning on server-side includes, for example, or turning on PHP inside of plain HTML files instead of requiring people to type PHP at the end of their URLs, which some people might not be very comfortable with. So the first thing we're going to go, this is how you turn on Apache and how you set it up so it will actually look at HT access files in your browser.
in your sites folder. Now by default on the client installed Mac OS X, htaccess files are ignored. So this is the first thing you'll have to do. And all you do is you add in for your username. Let's say you're logged in on this machine that I'm gonna show you on. You're logged in as Apple, so we'd call it apple.conf. And we provide these options inside of there. These are all options that you can look up in any Apache configuration module. And on the DMG, I provided all these files for your reference so you don't have to copy them down. Now this basically turns on HT access files. Once you install these commands in your user configuration file, you go and just restart Apache using either the checkbox, or you can do it by using the sudo Apache control command.
Now for site one, I'm going to show how to turn on server side includes for HTML files. What those are is basically they're a special kind of HTML comment. And you put some contents in there. And what that'll do is when the server's vending out the file to various web browsers, it'll look on the disk to find a file by that name. And it'll replace the comment with the contents of that file. A lot of people use this for standard headers and footers on their websites. So this is kind of an interesting option to turn on, 'cause then you can have standard headers and footers for all your pages, of course. Now in site two, we're just gonna turn on, we're gonna use these commands to turn on PHP processing inside of plain HTML files. So now instead of having.php at the end of all your files, you have.html. And for some people, well, they can't really tell how you're automating your site then, because you're just using HTML as far as the world is concerned. Behind the scenes, of course, you can have PHP running processing your pages. So here's a small demo. I'm going to switch over to Demo Machine 2. First of all, here's the HTTP configuration file that I'm using. And inside of there, I've enabled the PHP commands. So here's the first line. And all I did was I took the comment symbol off the front of that. And here's the second one.
So searching from the top, there's the load module statement. We uncommented that. And then we uncommented that. And that's turned on PHP on your system. And you can use PHP in all your files. And after that, you probably don't want to do any more changes to the HTTP configuration file. Now in here, this is my Apple user configuration file. And that's located inside of-- well, you can see it up here. It's et cetera, HTTP users, Apple configuration.
This is the important statement here is just allow for HTTP config, HT access files to be used. And that governs the access over, you provide an absolute path name up here, the user's Apple sites directory. So everything in the Apple sites directory, now if there's an HT access file in the folder, it'll be used to determine the options for that folder and all the sub folders of that folder. Thank you. So these are standard Apache configuration things.
So I have site one set up here, so we can say, local host, local host. Site one. So that's my site with server-side includes turned on inside of it. And if we look on the disk here-- As far as zooming in the finder windows, I could try doing that. Oh, hold on, yeah. Give me a second to do that.
It's on? Turn on Zoom. Thank you. Thank you. - OK. I guess when I'm in front of people who are nervous, I'm not looking at the thing in front of my face. OK. So anyway, here's site one. And here's my HTML file. And of course, here's my include file. Now inside of there is a Control Option plus. OK.
So here we have the-- this is the service ID include statement there. And basically what happens when the file gets read in inside of the browser-- if I can find Safari now-- Okay, so if we view the source here on this page, we can see that that comment was replaced with this text here, which is inside of my include file, and that's where it was replaced. So that server-side includes inside of site number one.
brought up the help for me. It knew I needed help. OK. Now inside of site two, I'm doing PHP processing inside of an HTML file. So if I make this more obvious-- So here's all the content that you can see inside of this page, and this is all generated from the PHP. Those of you familiar with PHP will be familiar. This is the PHP information command. I'll show you the contents of that file as well, if I can get back to the Finder. So I'm not actually using the header include file there.
So here's all the PHP that's being generated here. That's the PHP command. And of course, This is all the content that's being generated there. So that's my little demo. It's not that exciting. If you're expecting some flashy web stuff going on, then, well, that's not there. But we'll switch back to the next slide.
So that's how to do-- those are simple websites. The problem you might notice there is you have to use tilde username, or tilde username, then the name of the directory. And that might not completely reflect what you're doing on the web, because usually you have something like mysite.com. And you want to mirror that kind of thing. So what you'd want to do then is set up a local virtual host. And what that does locally on your machine, instead of using the word local host to refer to your site, you'd set extra name to refer to your own computer. So what we do here on the first little section we see up there, what I've done is I've added a name alias in for local host on my machine. And we're calling it local name. I think in my demo I'm calling it local site. And then in the next part, we add this virtual host section into our configuration file. Now the advantage of this is if you're doing debugging and stuff on your site, then of course you get server side logs generated for your virtual host.
And you can have as many of these set machine as you want. You can set up local host, local site, local this, local that for as many different sites that you're building. You'll get a server side access log, you'll get a server side error log, you can set up a document root for that directory, which means if you understand a little more about the server side include thing, you can do include virtual rather than include file, which goes to the document root looking for documents rather than relative to the source file. The other thing you can set up also is a scripts directory too on a per host basis. But now I have a demo of this. that I'd like to show you. And I'm going to build this on the computer here.
So the first thing we bring up, here's our configuration file for my Apple user. And I'm going to add in-- the virtual host part here. So here's the local site, is the name that I've set up. And inside of-- here's my host file. I'll make that bigger, too.
So inside of my, this is my host database. Once you edit this file, you don't have to restart your system or anything. So I'm adding in, here's local host. I'm adding in another site, another name alias for that IP address called local site. And then I'm setting up a virtual host here. And the document root is going to be site three inside of my sites folder for my user. And I'm going to log errors and accesses in these two files here. So once I save these-- then we'll be able to go into-- we need to go into the terminal so it reads in our new configuration. And I'm doing the Apache Control graceful method to restart the server. And then I can go into-- You can see the site name that I'm typing in there. Okay, there's my exciting demo. But what's going on in the background here is this is reading in the configuration for that site. And I've set up site 3 here, and that just has a server site include. And I've done the normal thing here. Now, htaccess files are in all these folders, and we can open those up inside of the terminal here. I'll go in there and open one up just so you can see it.
So here's our htaccess file right here. And there's basically the commands that I have inside of it, server-side include, parsing, turned on. So that's a very simple way to set up a virtual host inside of your machine. And that way you can basically emulate the same functionality as you have on most websites to install whatever software you need on those. Now for more information about Apache configuration options and stuff, there's a really good book by O'Reilly. And there's also the Apache website here that you can go to. And I also mentioned Darwin Ports, because if you're interested in installing other server software other than Apache, you can go there. And they have a whole bunch of different servers that you can install on your machine that are kind of interesting to play with. Or if you have special servers that you're developing for, then that's a good place to go and get the server software that you can install.
So in our next section, I'm just going to go over the different databases you can install in your system. And I'm not really going to do any demos here, because, well, databases, that's even less visually interesting than my last demos. So what you can install, I'm gonna go over MySQL 4.02, PostgreSQL, and Berkeley DB, and of course, you know, there's some others that we have available on the platform as well. These are the free ones, but there's other ones like Oracle and Sybase that you can get as well. So I'm gonna talk about... MySQL, where you can get it, there's a really good double clickable install system style package that you can install from their site. You can go to their mysql.org. It's a fast, popular database. It's used in almost every web server seems to have it these days. I think a lot of people are using it. So that's a very popular package that you might want to look at.
PostgreSQL. This is a more advanced-- supports more advanced SQL queries that you can use. And it's more interesting if you want to do some advanced programming. Now, they do have an install on their website at postgreSQL.org. But there's also a really easy to use install on Darwin Ports that you might want to install instead, because that's all pre-configured, and there's no hassle installing it. It's very easy to do.
If you do install the Darwin ports, they have variants. If you want it to run as a server on your machine instead of just installing the libraries and software that is not launched by default when you restart your computer, then you'd want to use the plus server option that I've shown there in the Darwin ports install command.
Berkeley database, I've seen some people use this with Perl. Some people do that and I've included reference to their website here. It's also available as an install package from Darwin Ports and that's why I provided a reference there. Now, there's some high level SQL tools that we can use. And, There's the Cocoa MySQL, which is really easy to do. And that's kind of for looking at MySQL databases. It's a high-level viewer engine that lets you do SQL queries and lets you look at SQL data and that sort of thing. The second one is MacSQL. And that's kind of a generic database product that you can use for viewing databases. And you can download that from Runtime Labs. What that provides is a UI on one end, and then you have various drivers for different databases that hook up. in between there that you can use. And then of course there's your database running on your other machine. PHP My Admin is another tool that runs in PHP of course. And I began the session saying I wasn't gonna do a demo, but I do have a demo of this. So I'm just gonna give a quick demo of using PHP My Admin. Now.
So if you go to their website-- and that's what I've done here-- we can download it. There's a gzip package. And I'll just download that. And hopefully it'll appear on my desktop. So basically the demo here is I'm just going to download the-- I'm going to have to cancel this demo. I'm very sorry. What happened was originally I had MySQL installed on this machine, and I forgot to do that just before our session. And it was really neat because what I do is I download PHP MyAdmin, just drop it into the site, and then it would work. But we'll just move on to the next slide, I'm afraid. Sorry. I just got here before, and I completely forgot to install that last one. So anyway, here's the database software references. And we have MySQL and their various websites.
And also you might want to look at Darwin ports If you're using things like Python or Perl or PHP, there's a whole bunch of plug‑in modules for various different database accessing drivers that you can get from Darwin ports. Of course the Perl ones you can get from CPAN.
Now we're going to talk about scripting languages next. And there's a whole bunch that are installed on the Mac OS X by default. You, of course, get PHP, Perl, Python, and Ruby. And there's all the old Unix favorites, the command line tools and whatnot, but you don't really use those for scripting web pages, but you might use them building web pages, of course. Now I'm going to start by talking about PHP because I think that's one of the most popular ones for web developers. Now, of course, you need to turn that on, and here's the commands that you can use. I showed how to turn it on before, but these are basically the two lines that you uncomment to turn on PHP for running in your programs. And all you have to do is take out the sharp symbols at the beginning of these lines and restart your Apache and that'll get it going.
Now, for PHP configuration, the default configuration, I found, I didn't really like it. So these are the two things that really bothered me about the default configuration for PHP. And you can, of course, go and change those. We provide all the defaults in a file that you can make a duplicate of using the command that I've shown here. And what you'd want to do, like, for example, the magic quotes thing, that kind of caught me by surprise. Because what it does is in the GPC stands for get post cookies. And in all the get post cookie data, it's on by default. And it puts little backslashes in front of all your quotes and things like that. So you might want to turn that off. The other one, if you want to upload files larger than two megabytes or have post data, which is tied to the upload, the maximum file size, greater than two or eight megabytes, then you might want to adjust those parameters. So you'd go in and make a duplicate copy of the default initialization value variables for PHP that we provide.
And then go fiddle with the preferences so they're the way you like them. Perl is installed, 5.81. We have Perl 5.81 installed on Panther right now, and if you want to upgrade that, you can go to Darwin Ports, and of course you can download that. That installs in a separate directory, and it doesn't overwrite the systems Perl. That's a good thing, and you can talk to me after if you want to know about ways to go about aligning that. Now... Of course, once you install Perl and you have the latest Perl installed, you can go and use all the CPAN modules and the DB database accessing modules and database accessing drivers for various databases and stuff like that. Mod Perl is available, and you can turn it on in the same way that you can turn on the PHP inside of the Apache configuration file. I'm not really going to go over that, but if you know about mod Perl, then you know how to turn it on.
Python is installed. There's a whole bunch of Python updates and modules from open Darwin. That's a really good place to look for that. Of course, here's the Python website. I was really impressed by how many different Python modules were available on the Darwin port site. So you might want to take a look at that. It's kind of a neat language.
Ruby, it's more of an object-oriented version of scripting languages for people that like object-oriented programming. It might be something really worthwhile for you to investigate if you do a lot of object-oriented stuff. And here's their website. You can upgrade Ruby, and there's a whole bunch of Ruby modules for accessing databases and whatnot on the Darwin Ports website. So that's the scripting languages section. We talked about Darwin Ports, and that's a really good place to go. It's one of my favorite sites, if you haven't noticed. There are a lot of scripting modules there. Other languages you can get. If you're building your web pages dynamically, you're using different languages to create them, there's a whole bunch of other languages you can go get there. And if you're writing C programs that do image manipulation or automatic image generation for like raster titles or something like that, there's a whole bunch of different libraries you can get there as well. So here's some information about different places you can go to find information about these different scripting languages, of course. There's the man pages and the pro doc pages and stuff like that built into the system as well.
So the last section, we're going to talk about server-side Java implementations available on Mac OS X. And the first section is Java servlets. Now, for those of you who don't know, Java servlets are little Java programs that run inside of Apache. And you can actually run them as a server inside of Apache as well. And now we're gonna show you some of the tools that we have available on Mac OS X for developing servlets. You can develop them inside of Xcode. And we have Ted Jucevic here to give us a demo of what they are and let you see how they work.
I'm not sure if they can hear you. I assume that people can hear me. So let's actually go to, I guess, yeah, that's the right machine. So the only thing I've really done for this machine is I've downloaded and installed the application server preview. You can get that from connect.apple.com. It says it's a preview, but it actually has final candidate implementations or releases of JBoss, Tomcat, Ant. XDoclet. It also includes templates for Xcode for doing, let's see, servlets, enterprise Java beans, and enterprise applications.
Now, what I'm going to show you here, I've actually got the server up and running. Where is that mouse thing? There it is. Don't worry about the text. I don't need to zoom it in. But this is just the log file that comes that startup, JBoss, this is what it generates. The only thing I've done is after you install it, you can actually start it up by going into CDing into library, JBoss, 3.2, bin. And then there's a run.sh script that you can run. And then you're up and running with it. So the next step is let's go and actually launch Xcode.
Now servlets, yes, it's Java and stuff like that, but it's not complicated. Even if you really don't know Java, to do a very simple servlet is very easy. One of the key things is, even though I'm doing the development for this on Mac OS X, you can deploy this to any other server that does servlets, any other server that has Tomcat or the JBoss with the Tomcat, Windows, Linux, Solaris, of course, XServe. And so I'll just put this in my home. Let me put it-- let's call it hello wwdcsf.
So it creates a project. This is actually an AMP build script that it uses. So if you want to-- say you're working on this project with other people and they're using some other tool, say like Net Beans or-- Eclipse or something like that. It's all just Ant, so it's all cross-- you can use it on pretty much any machine. So I'm going to go ahead and do a build.
But actually, before we do anything, let me just go into the source and make a change here. And the change that I'm doing is actually just-- Let's see, that's the title, and then this is the content. The template comes up with Hello World. And let me see if I can zoom in on this a little bit. Let me get the text. Let me set it to, let's see, like 18.
There we go. So let's go down to here. And the do get, this is when you send a get command to the server. This is where it comes in. It actually sends in the request. the response, and essentially everything that you're printing out is in these quotes. If you have just a static page or something you're generating or something like that, you can pretty much just fill in these quotes, but that's not what a servlet is. It's supposed to be dynamic and all that. But what you can do is you can take this request data and then based on that reply with whatever you want. So I'm going to go ahead and change this to WWDC.
And oops, that's a habit. And let's go ahead and do the build. Now, one thing about this AMP project is it actually does both the build and then also installs it. So you notice that the terminal over there just kind of kicked up. What that was is the AMP build actually copied it into the directory for you. JBoss, or actually Tomcat in this case because it's a servlet, notice it was there, loaded it up, and you're up and running. So the next step is, of course, to test it.
You could always go to another machine, but you're on that machine. And actually, I changed it a little bit from what I had before. So the first part of the URL is actually the name of the project, sf. And then the second half of the URL, the server hello world, actually comes from inside the sources. There's the xdoclet comment right here, the server hello world. With that, you can configure exactly where you want it to be accessed from on the server and stuff like that. So if you have multiple of course servlets, you don't want them all to have a collision space on them. With any luck, I should get low WWDC.
Um, so, of course, your servlets would be much more dynamic and stuff like that, so, um, but, you know, the entry level for servlets is very low on Mac OS X, and it makes it very easy to develop and then deploy to any other platform. So thank you very much. Thank you.
So thank you, Ted. Ted's one of our engineers in Apple for technical support that takes care of Java. Now, for the next section, we're going to talk about J2EE application development on Mac OS X using WebObjects. WebObjects is Apple's rapid application development technology for developing websites, and it's for building J2EE applications. We're going to show you how to use WebObjects. Most people think of WebObjects in terms of, well, you have to have a WebObjects server, but we're going to talk about it in terms of, well, we're going to just use WebObjects for developing J2EE applications for placement on any server in the world. doesn't have to be a WebObjects server.
And that's kind of interesting in itself. Now, to do that, I have Daryl Lee, who is a senior engineer from the WebObjects team who's come to give us a talk and give us a demonstration of how to do that. So here's Daryl. All right, thank you, John. So how many people out there know what WebObjects is or have heard of WebObjects? Great. How many have worked with J2E technologies before, EJB, servlets, et cetera, et cetera? Okay, great. So what I'm going to tell you about is how WebObjects and J2E kind of integrate well together. So what is WebObjects? It's a Java application server that Apple builds. It's a development and deployment environment. So we think it's probably one of the best ways to build large enterprise-level applications that have a lot of enterprise needs. And some of the vertical customers or solutions that people have deployed have been for online banking institutions, solutions, travel agencies, e-learning solutions. We use it for our iTunes music store, our.Mac services, our online Apple store also. So there are many other solutions that are out there, but that just gives you an idea of what people have done with it.
So at its core, what is WebObjects about? I think the power of WebObjects is in our core frameworks. And we have frameworks, if you've heard of EOF, that allow you to model the data in your database or other data sources and connect to that easily and map that to your application. Then we have a bunch of frameworks that allow you to publish your data either to HTML or maybe a desktop application, a Java desktop application, or maybe build a web service. And so on top of those frameworks, we have a bunch of tools and assistance that help you configure your UI and build your applications rapidly.
So if you're familiar with WebObjects, a lot of people have done what we call a.woa deployment or the application bundles are bundled in.woas. We also have a different option for deploying in J2E containers, and that's the.war bundle. And.war bundles or web archives are a J2E-specified way of deploying a application bundle server. So if you have something like JBoss, you can take a war bundle and deploy it into that and also take that same war bundle and deploy into WebSphere or WebLogic or whatever J2E container that you'd like.
So let's dig a little deeper into the functionality within WebObjects. So the first thing you want to do is get some connectivity to your data. The standard way in Java is to go through JDBC, the JDBC interfaces. So if somebody writes a JDBC driver, then we can connect to that kind of data source. So today we've talked about MySQL or Postgre. There are JDBC drivers for that. There are a lot of commercial drivers for like Oracle, Sybase, and you name it.
So if you're connecting to relational databases, we can support that. And in the same token, if you're connecting to directory services, Java has a standard interface for that. So the JNDI interface is the way to go. And things like OpenLDAP and iPlanet, we can support that kind of connectivity. as long as they have a JConnector for that. So when you're trying to map your data from your database, we do this thing called object relational mapping. So we're mapping the actual tables and rows in your database to actual objects so that your app can access that. And we have an EOModeler tool that I'll show you a little bit later and how to use that tool. So the next thing after you've kind of modeled your data is you'd want to figure out what mediums or where you'd want to publish that to. When you hear the name WebObject, you think, oh, OK, so that's a web client. So we obviously vend HTML as one option. But some other things I want to make you aware of is that if you want a richer experience, we also help you build Java clients for the desktop. These are kind of three-tiered applications. So they would be a Java client, which would talk to a WebObject server, which would then talk to your database. And then we also support web services. So web services are a very popular buzzword lately. And so if you hear Microsoft is pushing.NET services and basically they're just sending out soap structures if people are familiar with soap. So web services kind of encompass SOAP, XMLRPC, and WSDL. I'm not gonna go into all those acronyms, but we have assistance that allow you to take your data with your model data and actually configure a service so that you can interconnect with other computers or applications that can talk web services also. So after we've done that, we're gonna move I want to just tell you about our rapid development tools. And these assistants really allow you to rapidly prototype your applications within minutes. So later in a demo, I'm going to show you that within five minutes, I can build an application without writing even a drop of code and customize the UI and get it up and running. So it's definitely a powerful tool to use in our WebRx distribution.
So getting started, what do I need to get on my disk to download on my laptop today and get running? Well, first you're going to want to pick a nice IDE to work in. We're Apple, so we encourage you to use Xcode. It's a great environment for building Java applications and WebObjects applications. So definitely check that out. If you are more partial to an open source solution, grab Eclipse and download that. And then we have a couple of open source projects that support WebObjects development. So if you have heard of WoeLips and WoeProject, we download those and install them, then you can use Eclipse to build WebObjects applications.
The next thing you want to do if you don't have WebObjects on your disk is to go to our website, www.apple.com/webobjects, and download a free trial version of WebObjects. It's their full-featured development tools there. The only thing you need is a 30-day free trial license. So that'll get you up and running, and you can play with everything that we got.
So if you're interested in the.war bundling that I was talking about and deploying that way, we have--I would suggest that you download the application server update or preview that Ted was demoing earlier, and that has Tomcat and JBoss. So those are all pre-configured to run on Mac OS X, so it saves you from downloading the binaries from jboss.org or tomcat.org and getting all that installed correctly and configured correctly.
Okay, so without, I would like to jump into a demo, and if we can go to laptop, the laptop over here. Okay, so this is kind of like the end product of what I'm going to show you, and what you can see is that this is a very full-featured app. I can add records over here. I can edit records. I can delete them, and I can sort them, and hopefully my session hasn't timed out yet, so it's still interactive. So this is what we're going to try to get to by the end of my demo. One other thing I want to point out to you, just because it looks cooler, is a more fuller model that I've built.
modeler. OK, there we go. So let's resize that. So if you look at this, and let me put this in a diagram view, which is much more interesting to look at. This is some data in my database that I've modeled. And what I've just selected here is the agent entity, which represents a table in your database. And say this first name attribute, what we call attributes, really represents a column in your database. And if we do get info, we can kind of get a little bit more information, like the actual column name is first_name.
So I want to build a simpler model for you. One other thing I'll point out is that you also can see the relationships between the various tables, the foreign keys and the primary keys, and how they relate with each other. Okay, so let's build a simpler model and reverse engineer this from our database. And the first thing we want to do is I'm going to connect to a JDBC data source. connect to it with a JDBC connection URL. Hopefully that pasted in correctly. Oops.
The next thing it's going to do is ask me all kinds of questions about, do I want to be queried about relationships or stored procedures or other things? And we'll just take some very simple options and say we're going to ask about primary keys. The next thing it's asking me is, OK, what tables do I want to work with? And I just, for the simplicity of this demo, I just want to pick one table. And I'll pick listing address.
Let's finish. So here is our model. And it's really simple. And like I pointed out to you before, here's our table and there are columns. And one other thing I'll just point out to you, say I want to change something or if I was just modeling this on my own and I didn't have any database or any of the tables set up in the database, we can generate the SQL for actually creating those tables and those relationships, the primary keys, the foreign key bindings, and stuff like that. And you can execute that script or save it off as a script. Okay, so let's just save that model.
Let's put that on our desktop. Okay. So, what I'd like to show you next is how in Xcode we'd build a direct web application. And what that does is allow me to rapidly prototype a web application. And as you can see, we have a bunch of other templates for web objects. So if you're building a Java client or if you're building a web service application and there are variations thereof. But I'm going to do a web application today.
Let's just call this test and put it on the desktop. So we want to eventually deploy this as a WAR bundle. So I'm going to select that option. This is a standalone one where it beds all the jars and necessary resources that we'll need. And this is where we'd put our little trial license in.
If I wanted to add web services support, either vending web services or consuming web services, I would select these options. And what this is asking me for is whether I want to use JDBC type of access or if I need JDI types of access. And I will take just the standard frameworks that's added there, and let me just add our little listing model.
Now, what this pane is asking me is, okay, what kind of default template look that I want to start off with? I'm not forced to stick with this, but I will be configuring this a little bit later. So let's just go with a neutral look and then build and run our project.
So there's not a real lot of Java code in this project. As you can see, there's like three Java files. And there are a few components in here. And then there's our model file that we were just talking about. And this will launch and pull up my web browser here. And this is my application without any configuration. And as you can see, it's fully functional out of the box. So if I wanted to query on it, there's no problems. I can sort right away.
and I can add and do other kinds of operations on the table. So as you can notice, some of it's not so pretty. I don't like this apartment number of string that it's previewing for me here. And I don't particularly like how it's presenting the zip code string or something like that. So I'm going to show you how you can customize this without even have to recompile your code. And what I would do is I would select the Assistant and log in. And then I want to select this Customize link. And what that's going to do is it's going to bring up an assistant-- it's an applet that will help me configure some of the properties within the application. Whoops.
So OK, here's our assistant. Hopefully that's large enough for everybody to see. What I want to do is I want to change this apartment num attribute name to something that's more displayable. And I'll just call this apartment. And just to see how cool this is, let me just pull this up. So as you can see, it's still apartment number right here, or the old way of displaying it. But if I hit the Update button right here, it will dynamically update that, and apartment now shows in my application. I can do the same thing. Let's do it for zip code again. And let's just call this postal code.
And we can update that, and boom, it immediately updates. So we can save our changes. And let me just show you how the deployment in JBoss works. Okay, so we want to go to Xcode. And let me just point out one thing in our targets over here. And let's select that.
Now I can tell Xcode where to drop my war bundle by configuring this one property here, which is the servlet_webapps directory. And it's telling it to put into the JBoss deployment directory in /JBoss3.2 deploy. So I just wanted to point that out to you. If you had installed your application server in a different location, that would be good to know. Okay, so let's build our-- and deploy our server.
And once it finishes building, it'll automatically put it into the /library/JBoss folder. And while it's building and stuff, I'll just show you one other thing, a way you can tell that the JBoss server is up without having to look at your terminal or something like that, is if you go to localhost 8080 on the 8080 port and you hit that, you'll get this welcoming page. So it's a quick way that I use all the time just to check if my server's up. So let's try connecting to our application. I'm pretty sure it's deployed. Let's just try. So it's at test web objects.
And here is our application. We can log in. And we can query on it. And see, here are our customizations. And as you notice, we're on the 8080 port. So I just, hopefully it was clear to you that when I was in Xcode and I was building stuff, that that was actually the development environment.
But when you deploy, you'll have a different URL here. And you'll see the 8080 colon or whatever you map your JBoss server to. So hopefully that clarifies just on how easy it is to build a WebOBX application and how it's almost virtually code-free when you're trying to prototype your application for the web. So back to you, John.
So thank you very much, Darryl. Here's some reference materials for doing server-side Java applications. Now, okay, I'm going to sum up. And what we've talked about today is basically doing all your web development locally on your computer. Like, for example, you're all carrying around laptops. So let's say you wanted to do website development, testing, prototyping on your laptop without being connected to the Internet. This is what we've been talking about today. We talked about server software and how to set up Apache so you can do local serving off of pages. And so you can emulate all the server-side options that you'd have on a regular server on the Internet. such as server-side includes doing PHP and virtual hosting.
We talked about databases, where you can go to get them to install them, where you can find them on the web, some installation options for Postgre, for example, and where you can get modules to access them from various scripting languages. And we talked about some scripting languages that are pre-installed on Mac OS X and how you can turn on PHP and that sort of thing.
We also had two demonstrations of different options for doing service-like Java on Mac OS X. These were all running locally on a local machine so you can do your development testing, prototyping, all on the same machine. Of course we had servlets which are the simple ones and we had J2E application development with WebObjects which of course as you noticed that was our flashy graphics demo. So now in the end here's the reference library information. We have a connect.apple.com DMG that you can download at the end of the day today. And look for information and downloads for software that you can install to do web development and prototyping on your machine.