Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Technical differences between ASP.NET and Java Servlets / JSP

My understanding of JSP is that every JSP page on first load is compiled into a Java Servlet. Is this the same for ASPX pages (of course, not into a servlet, but whatever the ASP.NET equivilant is)?

What other technical differences should I be aware of with JSP and ASP.NET (MVC 2)?

like image 305
knpwrs Avatar asked Jul 30 '10 12:07

knpwrs


2 Answers

ASP can vaguely compare to JSP / Servlet. ASP.NET can vaguely compare to JSF (build on top of Servlet/JSP).

ASP.NET and JSF are both component-based frameworks, while JSP and ASP are mostly view technologies.

Done correctly, JSP/Servlet can be used to have an action-based approach where a controller process a command and forward to a view for rendering (MVC), which decouple view rendering from the business logic.

But the approach taken by component-based framework is different and each component can trigger callbacks (business logic) and is responsible to render itself. They also rely on the concept of data binding, which does not exist as is in action-based framework.

Component-based model are closer to programming model for desktop application, but abstract away the webby nature of the application. This is good and bad at the same time. It's bad when you want to optmize web-related things such as friendly URL, etc. That's I think why Microsoft introduced later on an action-based MVC framework next to ASP.NET.

like image 50
ewernli Avatar answered Sep 27 '22 22:09

ewernli


JSP pages are translated into Java source code, then compiled into class files (containing Java Byte Code) for future execution. After that, they're actually JIT (Just In Time) compiled by the JVM when they are needed for execution (so they're pretty fast).

It's my guess that there's a similar process for .NET applications, in that they are compiled into .NET assemblies. This is sort of like Java's class files, except they are IL (Intermediate Language) to run on the CLR. At run time, IL is also translated into native machine instructions for execution.

The actual build / runtime mechanisms (from a high level) are probably surprisingly similar.

EDIT

Here are some details regarding ASP.NET : http://msdn.microsoft.com/en-us/library/ms366723.aspx

Also, with Java based web applications, containers which run them can be configured to pre-compile JSPs when the application is deployed. Then, the JVM loads the class files into memory, and handles JIT compilation / caching from that point forward.

like image 29
Derrick Avatar answered Sep 27 '22 23:09

Derrick