Freigeben über


How does JSP work on IIS?

The following question is often asked - why IIS does not support using JSP directly? Allow me to explain what is really going on here...

Question:

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?

Answer:

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

Conclusion

What you need to run JSP:

  1. A web server that runs Java to load the JSP. Tomcat does this.
  2. 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.

//David

Comments

  • Anonymous
    January 26, 2006
    How and where can i get jsp plugin. And how to install it??

  • Anonymous
    January 27, 2006
    sandeep - There are many JSP plugins available for IIS - Tomcat, JRUN, JBoss, etc.

    Actual installation and configuration of any of them is beyond the scope of the blog since they are essentially different products with their own support groups. I suggest searching and deciding on a plugin and then locate suitable installation directions to use them.

    I am only talking abstractly about how these plugins interact and function with IIS to help in understanding and troubleshooting.

    //David

  • Anonymous
    February 27, 2006
    Question:
    Hello All,
    My client has a IIS 6.0 with some static pages configured in it.  My application...

  • Anonymous
    April 09, 2006
    try resin!

  • Anonymous
    April 17, 2006
    A couple of remarks:

    1) JBoss is not a servlet container per se.  It comes bundled with either Tomcat or Jetty to provide that service.  I second the motion to look at Resin.  So a good partial list of JSP/Servlet container candidates in a Windows/IIS environment includes Tomcat, Resin, Jetty and ServletExec.

    2) David: Could you suggest a good way to integrate the Windows Integrated Authentication with Tomcat's ISAPI-Redirect?  Is there a way to let the Java environment have access to IIS server objects?  I would like to have IIS take care of authentication while letting the servlet container handle my Java code.

  • Anonymous
    April 17, 2006
    The comment has been removed

  • Anonymous
    May 17, 2007
    I second with the point that any web server made on Java or .Net will be slower. This is because of the layer of abstraction which comes in to picture when these two language come into picture.

  • Anonymous
    May 24, 2007
    I'm interested in the distinction of doing kerberos delegation versus doing authentication on ISS and then forwarding the raw request back. Is it considered safe to allow the authentication to occur at the IIS level.  In other words the users authenticates to IIS via SPANEGO and then the JSP request is passed to the app server(resin) via the ISAPI filter and processed.  The java code would use something like request.getRemoteUser to determine which user is executing.  Is there any guarantee that that getRemoteUser is really the same person that authenticated at IIS? -Del

  • Anonymous
    July 04, 2007
    The comment has been removed

  • Anonymous
    July 27, 2007
    The comment has been removed

  • Anonymous
    July 27, 2007
    I made a mistake above - mysql & mssql databases are not a part of IIS. Also, I'm currently utilizing an ISAPI for the advertising panel capability (similar to yahoo geocities ad-panel on the right). As of now the panel will not be visible as the plugin is under development. Btw - I'm on a tight schedule and quick advice would be HIGHLY appreciated.

  • Anonymous
    August 06, 2007
    Chaitanya - I cannot think of any good, fast way to support JSP on IIS. If it already exists, then no one would want to run things like Tomcat on Windows. One basically needs to duplicate the work Microsoft did to support ASP.Net on IIS. You can view ASP.Net as a custom ISAPI which exposes .Net Framework onto IIS. Tomcat Connector is just another custom ISAPI which exposes Java onto IIS, but that ISAPI is a bit flaky because it just forwards the request from IIS instead of proper integration with IIS like ASP.Net. Someone's going to have to figure out how to integrate Java onto server-side correctly to make your life easy, but Sun's lawsuit pretty much make it impossible for anyone other than Sun to do this task, and they are obviously not interested. Clearly, Java is not "write once run anywhere". It is "Write once, run anywhere that Sun allows you to". //David

  • Anonymous
    November 25, 2007
    This is the best-written guide to getting JSP to work on IIS quickly stably that I've seen in a long while: http://neosmart.net/blog/2006/configuring-jsp-for-iis/ It's written by the team at NeoSmart Technologies, who have a long track record of providing quality info on configuring IIS to work with stuff from the Linux world :)

  • Anonymous
    May 07, 2008
    Hi everyone I want to run ASP pages on a server that already has Resin (for jsp pages) runnning, it works on my windows xp macine but for some reason the ASP pages cannot be found on the windows 2003 server machine... if I stop the resin engine, it still doesn't work, if i start Resin & IIS, it still does not display ASP pages. the error I get when the ASP pages cannot be found has a error at the botom of the page that states the name Resin #.#.#...EVEN when i stop resin. Please can anyone give me some advice. Mike

  • Anonymous
    May 08, 2008
    Mikee SA -  It seems like Resin just tries to process all pages as JSP, and since it does not understand ASP, it simply returns "cannot be found". This sounds like a problem with Resin since it is preventing ASP from working. I would contact Resin's support personel on how to fix Resin so that it cooperates and interoperates with other software. It is Open Source, it's supposed to do that, right? //David

  • Anonymous
    January 07, 2009
    Hi David, Nice article on JSP with IIS. http://viralpatel.net/blogs/2009/01/tutorial-java-servlet-filter-example-using-eclipse-apache-tomcat.html

  • Anonymous
    August 24, 2009
    Very nice and useful contains for new user

  • Anonymous
    September 01, 2009
    Good article,that clears the basic concept of beginners. well done

  • Anonymous
    December 29, 2010
    Nice Article with good Information.  Thanks David. Best Regards, Vijendra

  • Anonymous
    August 18, 2013
    IIS is just a web server and cannot support jsp or servlets. It needs a third party tool (JRun or Resin or Tomcat) to run jsp pages on IIS.so learn more about online courses on<a href="www.benchfolks.org/java-j2ee-training">java certification</a>,.net,my sql,sap and sas