Tutorial :What are the correspondent of Servlet and Applet in .NET?



Question:

I am trying to understand what's the correspondent of servlets and applets in .NET but I don't have much experience in JAVA.

I am thinking applets could be compared to the silverlight stuff, meaning you code independently from the browser, but then it's not like that since (between other things) you can re-use an applet outside the browser.

I need to demonstrate web technologies for a JAVA-based college-course and I can use .NET as long as I can demonstrate the same stuff.

Any help or ideas appreciated!


Solution:1

In .Net, HTTP handlers (.ashx) are probably the closest thing to a servlet. As for applets, there isn't a direct equivelent, but siverlight is probably the closest (although its closer to Flash/JavaFX)


Solution:2

I agree with Sandy, ASP.Net is best compared to a JSP (which is really nothing more than a specialized servlet). The .Net servlet analog appears to be the base class System.Web.UI.Page.

This sums up the comparison nicely (examples below blatantly plagiarized)

import javax.servlet.*;   import javax.servlet.http.*;    import java.io.*;    public class SimpleServlet extends HttpServlet {        public void doGet(HttpServletRequest request,               HttpServletResponse response)              throws ServletException, java.io.IOException {            response.setContentType("text/html");          PrintWriter out = response.getWriter();            out.println("<html><body>");          out.println("Simple Servlet Body");          out.println("</body></html>");            out.close();      }  }  //-----------------//  using System;   using System.Web;   using System.Web.UI;     public class SimpleServlet : System.Web.UI.Page  {      private void Page_Load(object sender, EventArgs args)      {          Response.ContentType = "text/html";            Response.Write("<html><body>");          Response.Write("Simple Servlet Body");          Response.Write("</body></html>");      }  }  


Solution:3

Java applets would seem to have their best analogies to WPF Browser Applications in .NET, if not Silverlight 2.0. There's no perfect mirror between Java and .NET in this respect - some technolgoies seem to be more similar to each other in certain respects and others in different respects. Given that Java was developed largely for the purpose of applets, and the .NET Framework for desktop applications, there are naturally going to be fundamental difference. Although WPF browser applications are of course restricted to the Windows platform (unlike Silverlight), they perhaps resemble applets more greatly in the respect that they can utlise the entire .NET Framework, among other things. Also, as has been pointed out, Silverlight is more analogous to JavaFX.

In terms of servlets, the equivalent is effectively the whole of ASP.NET (moreover the Web Application side as opposed to websites), though that is being slightly vague. Perhaps more accurately, JavaServer Pages most resembles ASP.NET (either WebForms or MVC [Model-View-Controller] for that matter). In the case of the former (Java), content is compiled into Java servlets, whereas in the case of the latter (.NET), content is compiled into .NET assemblies. So maybe .NET assemblies of web applications are most akin to servelets - though to be honest I don't know enough about the Java side of things to make much of a conclusion.

Interestingly, the histories of .NET and Java began somewhat differently (admittedly they were both VM frameworks, and Java inspired .NET), nonetheless in many aspects they have converged over time so that nowadays you'll pretty much find an equivalent technology in either of the two frameworks, though often in one there has been significantly more development and/or success (Silverlight is one example in favour of Microsoft, whereas applets are perhaps in favour of Sun). Anyway, hopefully I've at least provided an overview of where the similarities and differences lie in the two technologies.


Solution:4

The counterpart to Applets in .NET were ActiveX controls. Silverlight is meant for RIA, something analogous to Adobe Flash runtime.

Servlets can be compared to ASP.NET pages. On how they compare end-to-end read the following article on MSDN, http://msdn.microsoft.com/en-us/library/aa478987.aspx


Solution:5

If you are trying to do a demo and you want to show some similarities between .NET and servlets/applets then you may be able to do this: 1) Servlet demo: Create a .aspx file that just goes directly to the codebehind class. Using a browser, call the .aspx file and have the codebehind class respond.

I use servlets as a way to communicate with javascript ajax calls frequently, and in terms of behavior there isn't any difference, my javascript function doesn't know what language or technology it is communicating with.

2) Applet demo: This one is a bit trickier as Silverlight was designed, it seems, to compete with Flash, but you could just make a clock widget and put it up on a webpage, but then you can explain that with some good design either can run outside of the browser as well.

What would be great would be to do your demo in both languages just for a comparison to show that there are multiple ways to approach a problem, and there are trade-offs in which technology to use.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »