VerySimple Developer Blog
Technical Tips, Tricks and Rants.

Archive for the ‘Java’ Category

 
Mar
30
Filed Under (Announcements, Java, Tomcat) by Jason on 30-03-2006

the purpose of this document is to provide a walkthough for setting up a windows server running IIS to serve JSP pages alongside asp, html, etc. at the moment, this is a fairly complicated procedure. because microsoft does not natively support a competitive technical solution (JSP) and the java community does not necessarily like microsoft that much, there are few resources. this is surprising to me, as it seems a very natural thing to want as a windows server administrator.

although IIS does not support jsp pages, it does have a plugin architechture which they refer to as ISAPI filters. the solution for serving jsp pages through IIS is to actually install a second web server which runs on another port. the second web server we will install is called Tomcat and is provided through the apache foundation. in addition to Tomcat, you install an ISAPI filter that intercepts any .jsp file, forwards it to Tomcat for processing. Tomcat returns the results to IIS, and IIS spits it back out to the visitor. So IIS doesn’t actually processes the jsp page, however from the perspective of the web visitor, that is how it appears.

this document was written for Tomcat version 3 (Tomcat 5 is the current version) and as a result, the content is probably outdated. however, the basics are still very much the same. also we now have the good fortune of a more detailed how-to provided on the apache site which is found here.
[url]http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk/iishowto.html[/url]. you will probably have the best luck following the instructions on this page.

——————————————————————————–

original walkthrough below:

——————————————————————————–

This How-To provides start to finish instructions for setting up IIS to serve Java Server Pages (JSP). After successfully completing these instructions, IIS will work as normal, except when a JSP is encountered, it will pass it along to Tomcat, which will process and send the results back to IIS. This how-to doesn’t really explain how or why things work, but rather will get you up and running quickly with a configuration that will serve most people’s needs. You should definitely read the Tomcat ReadMe files for more detailed information.

The following file paths will be used in these instructions. If you install to a different directory, then you’ll want to change the instructions accordingly. These seem to be the default installation directories for the programs, except for Tomcat, which doesn’t mention a default installation directory.

Java: C:\JDK1.3
Tomcat: C:\Tomcat
isapi_redirect.dll: C:\Tomcat\bin
IIS Root: C:\InetPub\wwwroot

Part 1: Installing JDK and Tomcat

This first part is just to get the JDK and Tomcat up and running. Tomcat works fine as a stand-alone application, so the most logical place to begin is to get it running properly by itself.

Download (from sun.com) and Install Win32 JDK 1.3 to “C:\JDK1.3″
Download (from jakarta.apache.org) and unzip Win32 binary version of Tomcat (jakarta-tomcat) to “C:\Tomcat”
Right-Click on My Computer -> Properties, go to Evironmental Variables* and set:

TOMCAT_HOME = C:\Tomcat
JAVA_HOME = C:\JDK1.3

IMPORTANT: In the environmental variables, make sure “C:\JDK1.3\bin” is the first directory in your PATH. If you have installed other Java programs, they may try to put their Java Run-Time directory first, which will mess up your Tomcat installation. (It’s also good to keep in mind that if you install another Java application later, it might try to change the path and mess up Tomcat)

* On Win2000, The environmental variables are found on the Computer Properties Advanced tab. If you are on Win95/98, then you probably have to edit autoexec.bat instead.

Restart the computer to finalize changes to PATH
Go to DOS prompt, CD to C:\Tomcat\Bin and start Tomcat by typing “startup” (without the quotes). You should get a 2nd DOS window that is running Tomcat. If the 2nd window flashes and immediately closes, then something is wrong - most likely your PATH (See C:\Tomcat\logs\tomcat.log for info) You can make sure Tomcat is running by opening your browser to http://localhost:8080/ (NOTE: If you have previously installed Sun’s JavaWebServer, make sure it is not running because it also uses port 8080)
Part 2: Installing The ISAPI Redirector and jakarta Virtual Directory

In this part we are installing an ISAPI filter in IIS. What this really means is that when IIS receives a request for pages that meet certain criteria, it will hand it off to another program (Tomcat) to deal with processing, and that program will then return plain text to IIS, which is what IIS will send to the browser. We will also create a virtual directory that allows this to happen.

Download (from jakarta.apache.org) isapi_redirect.dll and copy to “C:\Tomcat\bin”
Download and double-click isapi_redirect_nt.reg or isapi_redirect_2000.reg to import the information into your registry. (If you have used directories other than the one’s specified here, then you should edit the .reg file appropriately before you double-click it). Note: You may have to reboot your PC after the registry update for changes to take effect.
Open IIS management console and create a new virtual directory called “jakarta” and make the physical path “C:\Tomcat\bin” Make sure that this virtual directory has “Execute” permissions.
In the IIS Management Console right-click on your machine name (not the root web) and select properties. Click the Edit button next to the “Master Properties” for the WWW Service. Select the “ISAPI Filters” tab and click “Add” Name the filter “jakarta” and for the executable, browse to C:\Tomcat\bin\isapi_redirect.dll file.
Now go to the control panel, select Services and restart the IIS Admin service (make sure Word Wide Web Publishing Service restarts as well). After you have restarted, go back to the ISAPI filters screen and make sure that the jakarta filter has a green arrow next to it. If it does, then everything is working.
Make sure that Tomcat is running. Open your browser to http://localhost/examples/ - you should see that Tomcat is serving this directory. There are several JSP examples which you can click on to test.
Part 3: Configuring Tomcat to handle JSP files, and IIS to deal with everything else.

This part we are configuring two things - telling Tomcat where the JSP files are going to be found (using server.xml) and telling the ISAPI filter which pages should be redirected to Tomcat (using uriworkermap.properties)

Open C:\Tomcat\conf\Server.xml in notepad and find the line towards the bottom that looks like this:

<Context path=”" docBase=”webapps/ROOT” debug=”0″ reloadable= “true”/>
and change it to this:
<Context path=”/” docBase=”C:/InetPub/wwwroot” debug=”0″ reloadable=”true”/>
(if that line doesn’t already exist, then just add it)
Open C:\Tomcat\conf\uriworkermap.properties with notepad. Add the following line anywhere in the file:

/*.jsp=ajp12

If you like, you can comment out the other lines that redirect the examples and servlet directories, although it doesn’t hurt anything to leave them there.

Make sure that it is working by browsing to http://localhost/ to see that your normal default page is still showing up as expected. Now place a file called test.jsp (or whatever) in C:\InetPub\wwwroot and browse to http://localhost/test.jsp If you put some JSP code in there, it should execute. If you didn’t, then the blank page should load. If you are prompted to download instead, then something is not working.
That is it. The final thing you might want to do is to install Tomcat as a service so you don’t have to open it in a DOS window every time. Instructions for installing the service can be found on jakarta.apache.org - look for “Working with the Jakarta NT Service” or “jk_nt_service.exe”

 

Close
  • Social Web

NOTE: Email is disabled

E-mail It