HOWTO: Demo CDs of Dynamic JSP Websites
Updates
I was able to try this procedure on a completely uninitiated PC, and found some alterations in the steps. I have highlighted them below [Updated August 30, 2007].
Goals
This tutorial describes the basic steps in putting your dynamic JSP website with a MySQL database onto a CD and make it run purely from the CD without installing anything on the PC. Please note that I am not affiliated with DWebPro or any other brands mentioned in this tutorial.
Outcomes
By putting your site on a CD, you shall be able to demonstrate the site on any PC without having to install Tomcat, Java, MySQL, or even a browser. Everything will run from the CD.
Requirements
The container for your JSP site needs to be Apache Tomcat in stand-alone mode. I have done this method successfully with Tomcat 5.5 and JRE 1.5.0_06. There’s some footnotes for other versions at the end of the tutorial. I am using MySQL as the back-end in this tutorial, but you can equally use other DBMS [see below]. Also, this works only on Windows PCs.
Getting started
We shall simplify everything by using a nifty software to do most of the technical stuff: DWebPro. Download it and install from here. I recommend using the defaults while installing. You will be required to register for free by filling out some info about yourself, and the download link will be sent to your email, after which you shall have 14 days to download or re-register. Note that this software can be used freely for non-commercial use.
Next steps
Next, we download the Java pre-package from here. After you finish installing it, then we download the Tomcat pre-package from here. Now install this and it will start working with DWebPro. Also download the MySQL pre-package here and install. I am using MySQL 5.0.15 here.
Setting up JDK
Now we are ready to get everything working. Because DWebPro uses Java 1.4, we will need to do a little upgrading. I shall assume you already have Java installed in “C:\Program Files\Java” and that you know how to download and install the JDK version 1.5.0_06 (or any version higher than 1.4 but closer to 1.5) You can use this page to get JDK. Choose the “JDK 5.0 Update XX” download button. ["XX" was 12 when I visited]Install it into your Java folder [as assumed above], then continue.
You will next need to locate the installation directory of DWebPro (I shall assume “C:\DWebPro” by default). In this directory, go to “\deploy\engine”, and first delete the “java” folder [see why later on]. Then copy-paste the JDK folder from the Java directory into the “C:\DWebPro\deploy\engine” folder.
Now rename the JDK folder in the DWebPro folder to “java”. At the end of this exercise, your “C:\DWebPro\deploy\engine” folder should look like this:
C:\
DWebPro
deploy
engine
java
tomcat
mysql
aspclassic
Deploying your site
Now that everything is set up (almost), you will need to copy your site into DWebPro. To do this, copy your site folder from your Tomcat directory (I assume you have it in “C:\apache-tomcat-x.x\webapps\”). Let’s call your site folder “my-web-site”. So you copy “my-web-site” to “C:\DWebPro\deploy\engine\tomcat\webapps\”. The Tomcat directory structure should look something like this:
C:\
DWebPro
deploy
engine
tomcat
webapps
my-web-site
WEB-INF
Next, copy your database as well. I assume you have MySQL installed in “C:\mysql” . So go there and open the “data” folder. If your database is named “my-db” then there should be a folder there with the same name. Copy this folder and paste it in “C:\DWebPro\deploy\engine\mysql\data\”. Your DWebPro’s MySQL directory should look like this:
C:\
DWebPro
deploy
engine
mysql
data
my-db
And with that we are nearly ready to Go Live! To test, run DWebPro from “Start > All Programs > DWebPro > Start DWebPro”. DWebPro shall take some time copying files (no need to get into technical details). When its done, Internet Explorer 6 shall open pointing to the Tomcat homepage [see below for why IE 6].
Now append “my-web-site” (the folder name of your site) to the URL when DWebPro launches the browser. For instance, the if the URL reads “http://127.0.0.1:8082″ add “/my-web-site” to make it read: “http://127.0.0.1:8082/my-web-site” and press “ENTER” or click “Go”. If everything is OK, your site will open.
Configuring Your Site to run JSTL and EL
This configuration is necessary if your website contains Expression Language or JSTL. More details are also available below in addressing different Java and Tomcat versions.
To configure Tomcat, locate your WEB-INF folder from “C:\DWebPro\deploy\engine\tomcat\webapps\my-web-site\” and open the “web.xml” file for editing. Now you will replace the “web-app” header of the file with this:
<web-app xmlns=”http://java.sun.com/xml/ns/j2ee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd” version=”2.4″>
If you had problems with the site when you opened it before, look at the task bar and locate the DWebPro icon. Right-click it and select close to stop the server. Now restart DWebPro and all the EL and JSTL should be working fine.
Pointing to your site automatically
When DWebPro opened “my-web-site” in IE6, we had to modify the URL to get to our site. It turns out that you can configure DWebPro to automatically launch your site without this extra work.
Go to “Start > All Programs > DWebPro > Configure DWebPro” and go to the “Browser” tab (in the top bunch of tabs). In the “Url” text box, you will probably see something like:
“http://127.0.0.1:##DWEBPRO_TOMCAT_PORT##”.
To this, add “/my-web-site/” so that the text box now looks like:
“http://127.0.0.1:##DWEBPRO_TOMCAT_PORT##/my-web-site”.
Lastly, click “File > Save”, and you’re done. Just to test, re-launch DWebPro, and your site will open by itself after everything loads up!
Burning to CD
Up till now, this might all be seeming pointless. So the site runs on my PC, but it did so before too with Tomcat and MySQL. Now things get interesting! I shall assume you have a CD burning software and know how to use it
. Go again to the “C:\DWebPro” folder but this time we are going to burn the “deploy” folder to CD.
Just point your CD burner to the whole of the “deploy” folder and burn away. Really easy! Now just find some non-geeky friend who won’t have Apache Tomcat with MySQL installed on their PC and pop in the CD. After a 5-10 minutes wait (sorry, takes that long for DWebPro to initialize), your site will open on their PC with all the data showing from the DB, as well as all the code running! Cool!!! Pssst… the friend will probably not be that impressed, its just some text and images showing after all
And its probably advisable not going into the thing about “stand-alone server-side web site without installing any server software”!
Needless to say, your database shall open as “Read-only” from the CD.
Version Issues
Up to this point, I have been throwing out explicit version numbers for most of the stuff used. That’s because all this can fall apart if the right versions aren’t used. This has nothing to do with DWebPro, but how the Java developers upgrade and downgrade their things. I won’t be explaining the permutations because this one worked best for me. But if you want to read more, go to the Sun Java forums.
Only IE 6?
On a side note, you might have noticed that DWebPro launches IE6, but you probably have Firefox installed
(or have upgraded to IE7). So how does DWebPro do it? The IE comes built into DWebPro, do you don’t need to worry about where it detects the browser to open your site. But if you want to use Firefox as the built-in browser, DWebPro also allows you do this. Just download the Firefox pre-package! It comes in version 2.0.
Only Tomcat?
Yes, right now with DWebPro, you can use only Tomcat for JSP and servlet development. If you use Jetty, checkout this super tutorial on how to make JSP CDs.
Em, What is DWebPro anyway?
DWebPro is, first of all, “The Best Free Stand Alone Server On The Market!!!”. Here’s an excerpt from their site:
DWebPro is a stand alone web server developed specifically for distributing dynamic web sites (for example PHP/MySQL, ASP.Net/Ms Access) on CD or DVD without needing to rewrite the web site code. With DWebPro, your company can easily create CDs or DVDs demonstrating the amazing capabilities of your web site, all while never being connected to the Internet.
I am using JSP and MySQL because that was what I used and needed help with. But DWebPro is simply huge when it comes to the number of server-side languages and DBMS it supports. Check out their site for the complete list. All you need to do is download the appropriate pre-package. They have extensive documentation on using each of these pre-packages as well.
If you need help from the DWebPro guys, they have a huge and super support system: Forum, e-mail, IM, phone, mobile, and fax.
Now I also need to make it clear that I wrote this tutorial because although DWebPro is extremely well-documented and has a great support system, there are some steps in making JSP CDs that have Java-specific issues.
Using other DBMS
I have used MySQL here, but I’m sure you can use any other DBMS just as well with JSP and DWebPro. You will only need to download the appropriate pre-package from their site and then follow similar steps for copying the data into “C:\DWebPro\deploy\engine\other-dbms” folder. This may be very specific to how the different DBMS store their data, so I’m not giving any instructions on it.
Credits
- DWebPro Support (I was about to give up when these great guys contacted me and helped me out!)
- DWebPro Help
- evnafets from the Sun Java Forums
The Alterations
When I tried this method on my PC, I took some of the steps for granted. But on another PC, the procedure wasn’t successful till I explicitly took certain steps. So I updated this tutorial to include these steps:
- The Java pre-package needs to be installed before anything else because it sets up DWebPro’s internal variables so that Tomcat and the default browser are aware of Java. Just pasting JDK, it seems, does not do the trick.
- We need to delete the “java” folder from DWebPro because its version is 1.4 and it will not allow EL and JSTL to execute within your JSP pages.
- The order of installing the pre-packages matters. The one written here is optimal. When I installed Tomcat before Java, the default browser did not configure properly for the JSP port in the URL [see above].
- I included a link to downloading the JDK.
Assumptions Made
I assumed that you installed Java in “C:\Program Files\Java\”
I assumed that you installed DWebPro in “C:\DWebPro\”
I assumed that you installed MySQL in “C:\MySQL\”
I assumed that you installed Tomcat in “C:\apache-tomcat-x.x\”
I assumed you installed the following DWebPro pre-packages: Tomcat, MySQL 5.
I assumed that your JSP website folder is called “my-web-site”, and your MySQL database is named “my-db”.
I assumed that you installed JDK 1.5.0_06 somewhere and can copy it.
I assume that you are fairly fluent in Java and JSP, and have had some experience with creating web applications.
I assume I remembered all the things I assumed and have written them here
Now predictably, most of these assumptions will be wrong. I only use them as guides. So if, for example, your database is not called “my-db”, just follow the steps with your real database name in mind and everything will be fine and simple
No comments yet
Leave a reply