Mr. Jeroen Frijters has implemented an JVM in .NET, IKVM.NET. It seems to be a good start.
Jetty vs. Tomcat
The first attempt was compiling Jetty to execute web applications directly. Digging into the source code and after a few trials, I found that Jetty is using Jasper library, which is Tomcat's JSP engine, to run JSP. Given that .Net does not have the concept of class file, it is unlikely .NET is able to load the create new class and load it into memory in runtime.
Jasper not only is the runtime engine of JSP, it also includes a JSP precompiler to compile JSP into Servlet. Using it is not hard but type the Java command is tedious. It makes sense to use IKVM to create a .Net executable. The Jasper library from Tomcat 5.5 is used:
Then compile the precompiler with this command:
ikvmc -classloader:ikvm.runtime.ClassPathAssemblyClassLoader -target:exe -main:org.apache.jasper.JspC -out:bin\jspc.exe *.jar
The command-line arguments of JspC is the same as the Java version. The following command can be used (%1 is the directory of the target web application):
jspc -uriroot "%1" -d out -compile -v -webxml "%1\WEB-INF\jspweb.xml" -trimSpaces -source 1.5 -target 1.5
The first JSP is a simple Hello World page to test out the JSTL EL:
Web Application Compilation
Everything are still in JARs and classes. However .Net Framework needs DLLs. The following command is executed to get everything in .Net assembly:
ikvmc -classloader:ikvm.runtime.ClassPathAssemblyClassLoader -recurse:%1\WEB-INF\classes -out:%1\bin\jsp.dll -reference:%1\bin\jspc.exe %1\WEB-INF\lib\*.jar
Servlet API, in .Net
Before running the DLL, the following classes are necessary in the Servlet API to run the JSP:
ASP.NET IHttpModule and IHttpHandler
The final bit is the ASP.NET module to initiate the configuration and the handler to execute the servlets/JSP.
I have made the source code available so you don't need to go through the whole process. Please visit http://jeans.codeplex.com/.