Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 720
JohnIdol Avatar asked Apr 02 '09 08:04

JohnIdol


People also ask

What are the differences between servlet and applet?

Applets are executed on client-side i.e applet runs within a Web browser on the client machine. Servlets on other hand executed on the server-side i.e servlet runs on the web Page on server. Important methods of applet includes init(), stop(), paint(), start(), destroy().

Which ways are used to communicate from applet to servlet?

An applet can communicate with a secure server using the encrypted HTTPS (HTTP + SSL) protocol. The CGI program can be used by browsers as well as applets.

What is difference between JSP and servlet?

Servlet is a java code. JSP is a HTML based code. Writing code for servlet is harder than JSP as it is HTML in java. JSP is easy to code as it is java in HTML.

Which package is used for servlet application?

Package javax. servlet. The javax. servlet package contains a number of classes and interfaces that describe and define the contracts between a servlet class and the runtime environment provided for an instance of such a class by a conforming servlet container.


2 Answers

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)

like image 79
JonoW Avatar answered Oct 23 '22 08:10

JonoW


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>");
    }
}
like image 32
nerraga Avatar answered Oct 23 '22 08:10

nerraga