Configuring JSP for IIS

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..

Install JVM

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..

IIS Configuration

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!

  • Similar Posts

    Craving more? Here are some posts a vector similarity search turns up as being relevant or similar from our catalog you might also enjoy.
    1. 100% Apache-Compliant REQUEST_URI for IIS and Windows!
    2. How To: Open Source + Windows + IIS... with Stability
    3. Request_URI For IIS Updated with ISAPI_Rewrite 3 Support
    4. No More Downtime!
    5. FastCGI for IIS Final Released, Congratulations to the IIS Team!
  • 82 thoughts on “Configuring JSP for IIS

    1. Thanks for this clear article.
      I have a virtual server that has exactly same configuration with above. I cannot get success after step by step configuration. When I request a mapped uri, the response is 404 everytime and Windows event log has error record about that isapi filter could not be loaded.

      Is the problem could be Virtual Server?

      > You need to set permissions on the the files we?ve just modified/created in order for the filter to work.
      Could you explain about permission settings more exactly please? Maybe the problem is that.

      Best Regards.

    2. I have followed the directions as stated, but still get 404 Not Found.
      I am not sure what you mean by this statement “to a Tomcat configuration that you downloaded earlier called ?neosmart'”. What configuration are you referencing? Workers.properties?

    3. Thank Friends,

      This is what i’m expected for long back. Now Jsp & IIS Integration makes one Milestone.

      Now Our client can use the IIS Security and Tomcat Servlet engine features together.

      Thank you.

      Arivuvel Ramu

    4. My best guess is that you didn’t follow this step:

      [quote post=”229″]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 you?re trying to configure[/quote]

    5. I’ve got a question, I’m running a website that has the .jsp file at the root of the website’s directory. When trying to load up the site, it gives me “The specified module could not be found.”

      Any suggestions?

      Harmeet

    6. Hello,
      I am having the same problem. I can access the jsp pages from tomcat but when i do through IIS i get 404 error.

      thats my uriworkermap.properties file.
      /jsp-examples/*=neosmart
      /WebApplication8/*=neosmart

      you did not mention, changing the registry any where in this article. is that allright?

      thanks

    7. [quote comment=”5410″]I’ve got a question, I’m running a website that has the .jsp file at the root of the website’s directory. When trying to load up the site, it gives me “The specified module could not be found.”

      Any suggestions?

      Harmeet[/quote]

      In your case it seems that either the path to isapi_redirect.dll is incorrect, or you haven’t given the proper permissions to the DLL.. Check both and post back 🙂

      @Waterlooguy:
      There are no registry changes to be made, but your bug can be solved following my comment above:
      You apparently haven’t added “*.jsp” as an allowed extension for IIS 6…
      Refer to where the article says: [quote]Next you need to tell IIS that these files are a-OK,[/quote] and do that step….

    8. Hello,

      These are very good directions. I have couple questions though. Before I ask my question, I just want to show how I have everything setup.

      It’s pretty much the same as above expect I didn’t download Examples and Documentation during Tomcat setup. I created “SampleWebApps” directory under “C” drive and “SampleWebApps.xml” under $CATALINA_HOME\conf\Catalina\localhost. Then, I tested Tomcat by http://localhost:8080/SampleWebApps and it works fine.

      I also added this “/SampleWebApps/*=neosmart” to “uriworkermap.properties”

      Now my question is, how do I link HTM, HTML, and ASP files to my JSPs. My JSPs are located under “C:\SampleWebApps\” and my other files are located under “C:\Inetpub\wwwroot”. I tried creating a hyperlink to “http://localhost:8080/SampleWebApps” but it didn’t work from another computer.

      I then created a “test.jsp” under “C:\Inetpub\wwwroot” and created a link from “index.html” to “test.jsp” but when I type “http://servername” it’s taking me right to the JSP. I don’t see the “index.html”

      I would really appreciate some help.

    9. By the way, when I type “http://servername/index.jsp” I get a 404 error. I know you mentioned that “Next you need to tell IIS that these files are a-OK” but how do I do that physically. I followed the steps in the above instruction very carefully.

      Again, I really appreciate your help.

    10. I did do the following if this is what you are refering to when you say ?Next you need to tell IIS that these files are a-OK?

      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.

    11. I have the same problem. I added the filter in the IIS MMC but the status is not loaded. I also added the virtual directory and allowed the filter to web service extension. the http://localhost:8080 is working and IIS is also working. But the http://localhost/jsp-examples/ is not working.

      What could be the problem? Why my filter is not loaded? Thanks.

    12. Dan,

      Port 8080 under tomcat is working for me. It’s just when I use port 80 for IIS. My isapi_filter is not loaded in IIS. I don’t know why? And the jsp-examples is not working either. But my html and php pages are working very well in IIS.

      From the tutorial mentioned J2EE SDK must be installed, I installed JRE only. Is that ok?

    13. This like all other instructions i have read do not work i can call all my jsp applications through localhost:8080/myapp etc but IT will NOT pass this through IIS, and its very very painful, i have been on this for 2 weeks and have gotten no further. Any help would be greatly appreciated.

    14. One of the files on our server had some extra information in it that caused some trouble for a lot of setups, we’ve fixed it now though.

      We also added a section in the “configuring new contexts” bit, that should help some people that could get the examples working but not their own contexts.

      I’ve personally installed Windows 2003 Server in VMware from scratch just to test this guide as it is at the moment: it works perfectly. Crystal.

      Please check the new “If it still doesn’t work” section, that should be very helpful, and I believe that is where most of the issues arise.

      Also, please redownload all the .properties files, as we mentioned there was some extra stuff that didn’t help.

    15. I’m trying to configure Tomcat 5.5 with IIS6 on Win 2003.
      I read a lot of documentation, and I followed your step-by-step guide too, but it doesn’t work for me.

      This is the problem: when I request a servlet or a JSP I get a 404 error. If I request a normal HTML file, there isn’t any problem.

      I have the green arrow, the “web service extension” is allowed, the isapi_redirect is the latest version (but I tried also an older version), I have the “jakarta” virtual directory configured properly, I have the “example” virtual directory configured properly, I copied the DLL in /bin (but I tried with /bin/win/i386 and with /conf, obviously changing the path on IIS configuration), in the tomcat/logs/isapi.log there isn’t any error, I tried the IIS 5 isolation mode too (without any success).

       

      What can I do? Any suggestion?

    16. Thank you for your fast reply.

      I forgot to write that I checked the permissions: everyone can “Read” and “Read & Execute” the DLL.

    17. Been over this exercise again and again but still getting a 404!

       

      Help!!

    18. Logged in user problem.. in my jsp i need to know how is the logged in user authenticated by IIS integrated security, is there a method ?

      For example:

      get /security/access.asp

      <- insert login/password -> 

      <- authentication ok ->

      get /MyVirtualJsp/test.jsp (here i have no header or reaquest.getRemoteUser() that works ??? )

       

       

    19. IIS 6 and Tomat

      The easiest way to Setup the JK connector is to get the 1.2.14 version first and use the msi included) upgrade later by downloading the jk.1.2.23 dll file

      Edit the workers.properties.minimal and uriworkermap.properties and Windows Registry as needed

      Add Server Side Includes in IIS 6

      Allow the JK isapi_redirect.dll in IIS as an allowed web service (ISAPI won’t show “green” until site is visited)

      Edit \config\server.xml… look for or add something like this to your file. This refers to your JK connector configuration.

       <Connector port=”8009″ enableLookups=”false” acceptCount=”100″ maxThreads=”256″ minSpareThreads=”25″ maxSpareThreads=”75″ connectionTimeout=”20000″ redirectPort=”8443″ protocol=”AJP/1.3″ />

      For IIS you sometimes need to enable “asset externalization” in one of Tomcat’s config files like product.properties. Also, somethimes just a virtual directory to Images, and another to content will do.

       

       

    20. what if i already have a website container that i want to use.

      I have currently a website container with 6 domains in it with php. asp and other technologies integrated. The website container is custom on another hard drive “not inetpub” How could i get Tomcat to handle the java proccessing of any of those websites without forcing to make websites in its own directories.

    21. Steve,

      The App Dir’s don’t have to be in the Inetpub folder.

      You can use a redirect to the appropriate web site’s IP or virtual dir and have those redirects stored in the inetpub

      Smitty

    22. I dont even use Inetpub.

      I use a custom wwwroot on the D drive.

      TO be honest i dont think java will be around too much longer. Everyone is going php and i can see why nowadays.

       

      Sun Microsystems has failed to keep integrating Java technologies up to date on Windows Servers and make the integration process on the fly. Its pretty bad when a server admin has to uninstall the latest version of a techonology and load a version 4 years older with all kinds of security holes and problems to make it work. Jrun is no longer compatible with latest version of JRE 1.6 and cannot be installed to run it on the fly.

       Sun Micrsystems never realeased a offical filter for there latest version of JVM.dll to handle servlets or jsp, applets or any technology to handle pre hyper text request on open tag pages. They never came out with a appropiate ISAPI Filter directly from them.

      Its pretty bad when you have to seek out other vendors like Jrun, Tomcat, or resin to make there technology work. Why they dont make the mappings or ISAPI filters themselves i have no clue. But its simply retarded

       

      Java appears to be dying.
       

    23. THanks for the info anyway btw Smitty. i have had Tomcat running before and Jrun both, it just amazes me after installing other technologies. How sun microsystems cant even make there stuff to work on windows IIS servers standing alone.

      drop me a line with your comments on it webmaster@area51solutions.com

    24. If you follow the steps outlined in the document, you will get your IIS / Tomcat working……trust me.

      Troy

      P.S.  Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!

    25. I  only got 404 from isapi_redirect.dll.

      With winxp, everything was ok, but win2003server SP1 didn’t work.

      The problem was some security settings:

      IIS -> Web Service Extensions -> All Unknown ISAPI Extenions

      I changed from ‘Prohibited’ to ‘Allowed’.
       

    26. Hans,

      That is a security risk; if you followed this part from the article above, you shouldn’t need to do that:

      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.

    27. I am unable to get the isapi_redirect.dll to load in IIS.  I get the red down arrow.  I suspect the problem may be permissions on the .dll.  On Aug 9 2006 you said:

      “Right-click the DLL and add iusr_COMPUTERNAME as a user with read privellages.”

       This step I do not quite understand, can you please provide further information? 

      By the way, if I click ‘Web Sites -> Services -> Run WWW service in IIS5 isolation mode’ then it DOES load that .dll however when I access the page (localhost/myapp/) I get this error:

      “HTTP Error 401.3 – Unauthorized: Access is denied due to an ACL set on the requested resource.”

    28. UPDATE:  I right clicked the .dll and added ‘Everyone’ as a user and gave them read privileges.  Now everything works great, green arrows and I am running locahost/myapp/. 

      However, is this a security hole?  I guess ideally I should add the “iusr” instead of everyone, however I don’t know how to do that.

    29. There is an account on your PC called iuser_something.

      This is the IIS generic user account. The “something” is the name of your PC. For instance, if your PC is named server_jimmy_neutron_3 then that’s what you plug-in instead of “something.” 😉

    30. I tried that (ie. IUSR_JKS47847894) but it just said ‘an object named XYZ couldn’t not be found’.

      However I then tried just searching for all users* and managed to find the ‘Internet Guest Account’ – added that and it works fine.  Have removed the Everyone option.

      * right click isapi_redirect.dll -> properties -> security tab -> Add -> Advanced -> Object Types: Users -> ‘Find Now’ -> select a suitable user -> OK -> OK -> check read permission is checked.

      Thanks for this guide, I would still be tearing my hair out without it.
       

    31. That’s why we wrote it 🙂

      See, it’s a little-known fact that the reason it’s guys that go bald is because it’s mostly guys that mess around with frustrating stuff like this 😉

    32. Computer Guru… Are you running JSPs on IIS 6 or did you have to change IIS 6 to “Run WWW service in IIS 5 isolation mode”? Everything I’ve read says to change it to isolation mode, which I can’t do because it defeats the purpose of using 6.

    33. Joan, we’d never write a guide that advises/entails the use of IIS 5 Isolation Mode 🙂

      All this is in plain 6. You can apply the steps (as we have done many times since posting this guide) as-is on a fresh install of Windows Server 2003.

    34. Update:

      I just noticed something that might have been a tad misleading: you need to also double-check the paths in the other .properties file as well.

      I’ve updated the article with a recommendation to open all the downloaded configuration files in WordPad/Notepad/Whatever and make sure they’re pointing to the correct path first.

    35. Computer Guru:

      Follow the same instructions you wrote for IIS 6 but do the following for IIS 7 support in Vista or 2008 server. If it works in IIS 6 it will work in IIS 7 with some additional steps.

      To allow IIS jakarta connector in IIS7:

      1. Install ‘IIS Metabase and IIS6 configuration compatibility’ feature under Server Manager.
      2. Install isapi_redirect. Go to IIS.
      3. Click on Computer Name
      4. Launch ‘ISAPI and CGI Restrictions’
      5. Add jakarta with path to your isapi_redirect.dll.
      6. Restart IIS.
    36. ive got tomcat installed works fine, but doesnt work with IIS, but that may be because the server im using is on XP not windows server 2003.   

       

    37. The instructions above are for IIS 6 (ships with Server 2003), not 5 (which ships with Windows XP); but should be similar enough to follow.

      Only change is you won’t have to do the allowed extension stuff.

    38. Ok ! I have configured this umptee number of times and have managed to get it work every time. It’s not always sure whether it’ll work the first time or not, but after trying 2-3 times it does work. However, with a new application we’ve run into a very peculiar issue. It’s like then we have IIS configured to service up our tomcat application over port 80. Tomcat itself listens for HTTP requests over port 8090 and for AJP requests over port 8009. All well and good.

      The problem we have run into is that the application sends some ‘response.sendRedirect’ responses based on certian conditions. TomCat while sending the redirect URLs is tagging on the 8090 port number to the ‘host’. That cause the redirects to fail because IIS is not listing on port 8090 (we have 2 servers – an IIS server that sits in the DMZ and a seperate Tomcat server that sits on an internal network).  The hostname is correct (it point to the IIS Server’s FQDN), it’s the port (http://IIS-FQDN:8090) that’s messed up ! How do we work around this issue ?

      Any help will be appreciated.

      Thanks

      Gurvinder

       

    39. I think (though I’m not sure if that’s your case with the info you provided) that this is the application at fault, rather than the configuration.

      The application should have an option for the domain name + port. In our case, we have it configured to the publically-accessible domain+port (neosmart.net:80) with the application path – this is the path the application generates for redirects and for links in emails, etc.

      If your app doesn’t have that option – you’re kind of in a bad place.

      You’ll need to have Tomcat associated with port 8090 on localhost only, and associate IIS on 8090 as well for external requests.

      Should do the trick.

    40. Hello,

      This works great for IIS, but I can’t for the life of me get it to work on IIS 5. The only step I see that doens’t apply to IIS 5 is the that I don’t have to add JSP as a Web Service Extension. Any ideas?

    Leave a Reply

    Your email address will not be published. Required fields are marked *