Many people love the ease and security of using Internet Information Services 6 server on Windows 2003. Adding PHP and ASP support is a cinch, and in no time at all, IIS 6 can serve anything you throw at it – except JSP files of course. By no stretch of imagination is getting JSP running invisibly with IIS 6 an easy job, and here’s the best way to do it.
In this guide, we’ll be using IIS 6 on Windows Server 2003 with SP1 installed, together with the Tomcat servlet engine (version 5.5.17 stable) to parse the JSP files that IIS may encounter. It covers all the prerequisites and how to get them up and running.
This guide assumes you already have II6 6.0 configured and running 100% with everything all right and trouble-free, and assumes Tomcat (and it’s prerequisites) isn’t already installed. Here goes..
Tomcat is a Java servlet, and requires the presence of Sun’s JDK to run. You can grab the Java EE 5 JDK off of Sun’s servers. Start the installer, make sure the J2EE Development Kit is selected if you’re doing a custom install, and let it finish.
If you installed it using the default settings, it should have installed the JDK files to “C:\Program Files\Java\jdk1.5.0_06” or something close to it, depending on the version you installed. Make sure you also let it install the JRE, you’re going to need it later. Write down or otherwise memorize the JDK location you used, it’s important.
Download and Install Tomcat
Grab Tomcat 5.5.x from the Apache Software Foundation’s website here. Download the latest entry under Binary Distributions -> Core. For quickest deployment, make sure to download the .exe file rather than the zip package. Run the exe, select “Full Install” and let it save to the default location (C:\Program Files\Apache Software Foundation\Tomcat 5.5), herein referred to as $CATALINA_HOME. It will ask for the JRE/JDK location, you will need to input the value you copied down earlier and continue.
When the setup finishes, start the service and continue. To test if it installed OK, direct your browser to http://localhost:8080/, assuming everything has gone well (no reason it shouldn’t), you should get the stock Tomcat welcome page – now that Tomcat is up and running all what’s left is to make it play nice with IIS..
The Jakarta/Tomcat project has lent itself to the creation of an excellent set of plugins and dlls: the Tomcat Connectors. The one we’re looking for hooks straight into IIS and is called ‘isapi_redirect*.dll’ where the ‘*’ is the version number. Head over to the Tomcat distribution site and grab the latest version of isapi_redirect.dll.
Once you have isapi_redirect*.dll, copy it to $CATALINA_HOME/bin/isapi_redirect.dll. Download isapi_redirect.properties to that same directory. You may need to tweak this file (in WordPad) if you installed Tomcat to a non-standard directory.
Download workers.properties and uriworkermap.properties and copy them to the $CATALINA_HOME/conf directory. You should probably open then in WordPad and double-check their contents against your directory locations for posterity’s sake.
Open the IIS management MMC, and right-click the default website -> Properties -> ISAPI Filters. From there proceed to add a filter called ‘isapi_redirect’ that points to $CATALINA_HOME/bin/isapi_redirect.dll. Apply changes and close the dialog.
Right-click the default website again, and this time add a “Virtual Directory” called ‘jakarta’ (without the quotes!) that points to $CATALINA_HOME/bin/ (the same place as isapi_redirect.dll). Give it ‘execute’ privileges when prompted. You need to set permissions on the the files we’ve just modified/created in order for the filter to work.
Next you need to tell IIS that these files are a-OK, and that it’s safe to run them. In the IIS management center again, click “Web Service Extensions” -> “Add a new Web service extension..” For ‘extension name’ enter “JSP” and for the executable file, locate $CATALINA_HOME/bin/isapi_redirect.dll, check “set this extension to allowed”, and then press OK.
Time to restart IIS. Stop it and start it again or just use the quick restart manager. To test Tomcat’s integration with IIS, point your browser to http://localhost/jsp-examples/ and if everything went all right… you’re done!
Configuring the Redirects
Remember the file you downloaded? “uriworkermap.properties?” That’s where you have to define the subdirectories in $CATALINA_HOME/webapps directory. For example, the file you downloaded had the “jsp-examples” context already defined.
/jsp-examples/*=neosmart tells it to transfer any calls to localhost/jsp-examples to a Tomcat configuration that you downloaded earlier called ‘neosmart.’
Adding more contexts is easy — once you’ve successfully configured Tomcat to run whatever webapp/jar file you want it to, (and that application is now successfully running on port 8080), simply add an entry
/mycontext/*=neosmart where ‘mycontext’ is obviously the name of the webapp (the subfolder) you’re trying to configure.
But in order to get it to completely act as a natural directory within IIS, you have to add another virtual directory. You can point it wherever you like, but you must have a virtual directory named the same thing as the context (for instance, if you have http://localhost:8080/jspBB/ you would create a virtual directory called jspBB in IIS). That’s to ensure that calls to http://localhost/jspBB work just as well as http://localhost/jspBB/ (note the end-backslash).
That’s it, you’re done! You know have a port-free address that redirects all calls invisibly and silently to Tomcat, the power, advanced features, and security of IIS with the added flexibility of Java Server Pages!
It’s Still not Working?
If it seems it’s still not working, i.e. you can view the pages via TomCat (by entering the port in the URL) but not by using IIS, try this:
The files you download are text files (obviously) with certain configuration bits in them. Open each one and check some of the values. Many contain paths to TomCat and the JDK: make sure the same paths that are in the file are the same as your configuration. Ensure that all of the paths work, there are no typos, and that all the files are present and in the right directory. If it still doesn’t work, http://neosmart.net/forums/ is the place to go. No support requests in the blog please!
excuse me, I meant to say it works great for IIS 6
actually, nevermind, IIS 5 is a bit slower than IIS 6 I guess
I just had to restart the IIS service, not simply start and stop IIS, and it worked
Thanks for letting us know it worked on IIS5, Shane.
Hiya! Really useful guide, has helped me lots. I’m setting up JSP 5.0 with IIS 5.1 (XP Pro), and it’s all working – i.e. http://localhost/jsp-examples – and they all execute beautifully – but I want to be able to use JSP files generally throughout my c:\Inetpub\wwwroot application… ASP, ASP.NET are working fine with IIS… and Tomcat is working perfectly on Port 8080. However, when I put a simple hello world script named first.jsp in the wwwroot folder, I either get the message “The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:” with the .jsp extension pointing to “C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin\tomcat.exe” and when I point the application configuration to “C:\Program Files\Apache Software Foundation\Tomcat 5.0\native\i386\isapi_redirector2.dll” I get the error “The specified module could not be found”. Last night I managed to get the page to load without any error but when I checked the source there was no output at all even with basic html. I’m gonna continue with this just now, but I’ve been at it for 2 days now… hoping to have a break tonight… if I get it working before tonight I’ll celebrate. Anyway, would really appreciate any tips!! Thanks in advance.
P.S. I should say that I’ve used setupjk204.exe which sets up isapi_redirector2.dll automatically for IIS and Tomcat… know that’s cheating, but the past few days I’ve spent setting it up manually and got no where… if you’re clever though you can look over the configuration files and see how it’s done for your particular system 😉
My configuration work fine.
But not working my pages .asp, look erro message:
HTTP Status 404 – /censo/index.asp
type Status report
description The requested resource (/censo/index.asp) is not available.
and the title tab is: Apache Tomcat/6.0.16 – Error report
my environment is: Win2003Server, IIS6, Tomcat 6.01.16, redirect.dll (ver 1.2.26)
Can you help-me?
Like it says in the article – support requests should go in the forums.
Please update the Java link above (under “Install JVM”) to:
The old one is no longer accurate.
Link fixed, thanks for the tip.
Im having problem configuring it to IIS 5.1 my tomcat is 6.0.18 and tomcat-connectors-1.2.27. I receiving an error of HTTP 404 – File not found. I dont found any errors on the logs anyone guys can help me.
Do you have any documents that cover IIS + Jakarta + Tomcat Single-Sign-On?
We don’t have any other IIS + JSP guides than this – what is it that you’re trying to do exactly? Which SSO provider are you using?
I might be able to give you a push in the right direction: NST currently has an SSO system running on Tomcat invisibly over IIS and everything’s running well.
Obviously, this does not work. In the beginning you state: [quote]This guide assumes you already have II6 6.0 configured and running 100% with everything all right and trouble-free, and assumes Tomcat (and it?s prerequisites) isn?t already installed. Here goes..[/quote]
I have followed these instructions without fault, many times. Even though this is the best tut I have found explaining this, it is not correct. I have gone through this 5 times and still nothing. I have added the IUSR and IWAM users to the entire directory tree, nothing. The only thing I am able to see is the http://localhost:8080 which leads me to believe that Tomcat is working. I cannot see the samples or the examples. When I have the isapi_redirect added in the isapi filters it will not allow my localhost (default web site) will not load. I check the isapi filters and the isapi_redirect-XXX.dll will not load with a red down arrow. Any help is appreciated on this. My e-mail address is email@example.com. Please feel free to contact me if you have had trouble with this and were able to figure it out. Thanks, Terry.
Obviously, it does work… or else a hundred people before you wouldn’t have posted their thanks.
“It covers all the prerequisites and how to get them up and running.”
No it doesn’t. According to the tutorial it says that this will work on “IIS 6 on Windows Server 2003 with SP1 installed”. Prove me wrong please.
Hi, can you help configure for IIS 7 with tomcat 6. Because i use Vista HomePremium, IIS 7 was default installed. Help me please.
Just want to say thanks and I got it working here with Win2003 sp2, iis6.0 and tomcat6, jdk1.6.0_12 (both latest at time of writing).
At the top you say requires JDK, so I installed the JDK but is it really nessesary? I wonder if just the JRE would have done. Also I wasn’t sure exactly which files to set the IUSR_ read/execute permissions on so i allowed all the files you mentioned. I’m not clear about these two points but its working so I’m happy.
Well Done ! and Thank You! It’s work.
Thank you ! This was the first reference that start to finish enabled me to get Tomcat working with IIS. The biggest piece I was missing was I didn’t have sample workers.properties files and uriworkermap.properties to work with.
Thanks for the clear instructions!
i guess i’m kinda too l8 for this post… but still,, i have got isapi_redirect workking fine on my machine. but i’ve got to connect it on my college website… is there a way that the connector doesnt disturb the default website and still runs my JSP content???
The way that i have corrected all the issues is to modify the above instructions a little. If you only have a single site the ones above will work fine. However we have 9 sites in our IIS configuration. Where the above instructions refer to Default Website you substitute your website. You will need to configure the jakarta virtual directory under that site as well as the virtual directory specific to the application.
For example we have
Employee SS (website)
>jakarta (bin folder)
>webapp01 (webapp folder)
Be sure to install the isapi_redirector on that web site as well and not on the default one.
Testing ours on the server fails but works fine live.
Could be wrong but is what works for us.
Thanks for the great article!
Just a couple of notes that helped me out. I’m running Windows server 2003 sp1.
I had to rename isapi_redirect-xxxxx.dll to isapi_redirect.dll; that wasn’t super obvious in the installation notes.
Restarting IIS was not enuff for me, had to do a system reboot and then everything worked correctly.
Right-click the default website again, and this time add a ?Virtual Directory? called ?jakarta? (without the quotes!) that points to $CATALINA_HOME/bin/ (the same place as isapi_redirect.dll). Give it ?execute? privileges when prompted. You need to set permissions on the the files we?ve just modified/created in order for the filter to work.
IIS 7 Windows Server 2008 – Does anyone have an update?
Hi guys, I was also having issues with this configuration. I was also getting 500 and 404 pages. but finally I got it to work by using following configurations:
I have windows 7, IIS 7, Tomcat 6.x, JDK and JRE 6.
make sure that you permissions for the DLL file.
make sure that your virtual directory is pointing to the same directory where you have your isapi_redirect.dll.
make sure that your tomcat is running.
make sure that you have allowed isapi_redirect.dll in the “isapi and CGI restrictions”
make sure that *.jsp is enabled in “handler mappings”
make sure that “isapi_redirect.dll” is “enabled” in “ISAPI filters” under “default web site”
make sure that there are no typos and all the paths are correct in you *.properties files.
There is also another very good guide with screen shots at http://www.iisadmin.co.uk/?p=72
if you still cant get it to work then tell me your exact problem, I will be happy to help you, happy coding !
I was able to get everything running, with the Tomcat logs showing clean worker logs and such, the example site seems to work fine, but for the life of me, I can’t get it to load any index.jsp pages. Have you got this working?
Good explaination ,
I am getting:
Service Temporary Unavailable!
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Copyright © 1999-2010 Apache Software Foundation
All Rights Reserved
Any idea what that might be?
Looks like the URL (address + port) in the Isapi Redirector configuration for Tomcat is incorrect.
Isapi Redirector is at least correctly registered on your system.
Could you please tell me how would I check all of that?
Can use what?
I have question regarding on connecting the jsp file to postgreSQL database.
Before this I work on my project on my own PC and it’s work successfully. But, when I copy this project to windows server 2008 and launch it, it’s error. The html page is appear when I type the url http://www.abc.com for example, then I need to login the username and password. After send the data, it failed and had http error 405. I had install the postgres in server but still not works.
What’s the problem actually?