The following question is often asked – why IIS does not support using JSP directly? Allow me to explain what is really going on here…
Does IIS 5.0 support the use of .jsp pages directly or do I need to use a separate server or extensions to IIS? Thanks in advance.
Thanks for your quick reply. One follow-up question, does IIS 6.0 directly support the use of .jsp or do I still need the 3rd-party add-on?
Ok, here’s how all of this works:
- From a request-serving perspective, IIS natively supports serving static files and execute add-ons (ignoring DAV for the sake of this discussion). This applies to all IIS versions.
- Ability to use dynamic scripting frameworks like ASP, ASP.Net, PHP, JSP, Perl, etc are all add-ons as far as IIS is concerned. These add-ons are configured as “Application Mappings” on IIS and map to certain resource extensions, and IIS simply executes the configured add-on to handle a particular resource extension whenever it is requested.
- Windows Server 2003 comes with ASP and ASP.Net add-ons in the default installation and they are configured (but not enabled) by default. Of course, you can still download and install any other add-ons to extend IIS functionality, including JSP/Servlet using Tomcat, PHP, or Perl.
- Just about all other web servers behave in exactly the same way as IIS in these regards, except they differ on what is bundled, installed, and configured by default.
Tomcat is slightly different and here is how Tomcat works with web servers like Apache and IIS:
- Tomcat includes a web server written in Java.
- Since it is writtin in Java, Tomcat obviously can “natively” run a JSP or Servlet, which is basically another Java class to Load, Instantiate, and Reflect as far as Tomcat (i.e. Java) is concerned.
- All web servers that are NOT written in Java (like Apache and IIS) obviously cannot run JSP without first loading Java code in a JVM to Load, Instantiate, and Reflect on the JSP page, and this is exactly the functionality their respective add-ons/connectors give to these web servers.
A popular add-on for IIS to run JSP on Tomcat is isapi_redirect, and what it does is basically the following:
- It still requires you to run Tomcat’s web server on a certain port so that JSP/Servlets can be configured and executed.
- It registers an ISAPI on IIS to steal JSP requests from IIS request processing, opens a connection to Tomcat web server, and shuttles the stolen request to Tomcat (i.e. it proxies the request).
- Tomcat sees this stolen request as brand-new, so it just executes it as-is, including your JSP page
- The response is sent back to isapi_redirect ISAPI, which then hands the response back to IIS to send back to the original client
What you need to run JSP:
- A web server that runs Java to load the JSP. Tomcat does this.
- If you want to run another web server for the real content, then you will need an add-on/connector to route requests between this web server and the web server in #1
Thus, IIS can never directly support the use of JSP because it requires an add-on to run Java code in a JVM to Load, Instantiate, and Reflect on the JSP page. The same can be said for every other non-Java web server because they have to do the exact same thing as IIS (so it is a matter of bundling and not capability). Meanwhile, Java-based web servers can obviously directly support JSP, but they are usually VERY slow in raw speed in comparison to native code web servers like IIS or Apache for everything.
In fact, you can say the exact same thing about ASPX pages – IIS can never directly support the use of ASPX pages because it requires an add-on to run .Net code in a CLR to Load, Instantiate, and Reflect on the ASPX page.
So, yes, IIS natively supports running JSP via add-ons, just not directly.