.NET中Servlet和Applet分别对应什么?

发布于 2024-07-16 17:10:19 字数 241 浏览 2 评论 0原文

我试图了解.NET 中 servlet 和 applet 的对应内容,但我在 JAVA 方面没有太多经验。

我认为小程序可以与 silverlight 的东西进行比较,这意味着您可以独立于浏览器进行编码,但事实并非如此,因为(在其他事情之间)您可以在浏览器之外重新使用小程序。

我需要演示基于 JAVA 的大学课程的 Web 技术,只要我能够演示相同的内容,我就可以使用 .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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

装纯掩盖桑 2024-07-23 17:10:19

在 .Net 中,HTTP 处理程序 (.ashx) 可能是最接近 servlet 的东西。 至于小程序,没有直接的等效项,但 siverlight 可能是最接近的(尽管它更接近 Flash/JavaFX)

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)

2024-07-23 17:10:19

我同意 Sandy 的观点,ASP.Net 与 JSP 相比是最好的(JSP 实际上只不过是一个专门的 servlet)。 .Net servlet 类似物似乎是基类 System.Web.UI.Page。

这很好地总结了比较(下面的示例是公然抄袭的)

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>");
    }
}

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>");
    }
}
葮薆情 2024-07-23 17:10:19

Java 小程序似乎与 WPF 浏览器应用程序有最好的类比.NET,如果不是Silverlight 2.0。 在这方面,Java 和 .NET 之间不存在完美的镜像 - 某些技术似乎在某些方面彼此更加相似,而另一些技术则在不同方面更加相似。 鉴于 Java 主要是为了小程序而开发的,而 .NET Framework 是为了桌面应用程序而开发的,因此自然会有根本的区别。 尽管 WPF 浏览器应用程序当然仅限于 Windows 平台(与 Silverlight 不同),但它们在可以利用整个 .NET Framework 等方面可能更类似于小程序。 此外,正如已经指出的那样,Silverlight 与 JavaFX 更相似。

就 servlet 而言,实际上相当于整个 ASP.NET(而且是 Web 应用程序端,而不是网站),尽管这有点含糊。 也许更准确地说,JavaServer Pages 最类似于 ASP.NET(WebForms 或 MVC [模型-视图-控制器])。 对于前者 (Java),内容被编译到 Java servlet,而对于后者 (.NET),内容被编译到 .NET 程序集。 因此,也许Web 应用程序的 .NET 程序集最类似于servlet - 尽管说实话,我对Java 方面的了解还不够多,无法做出太多结论。

有趣的是,.NET 和 Java 的历史开始时有些不同(诚然,它们都是 VM 框架,都是受 Java 启发的 .NET),尽管如此,随着时间的推移,它们在许多方面已经趋同,因此现在您几乎可以在其中找到等效的技术。两种框架中的一种,尽管其中一种往往有更多的开发和/或成功(Silverlight 是有利于 Microsoft 的一个例子,而 applet 可能有利于 Sun)。 不管怎样,希望我至少概述了这两种技术的相似点和不同点。

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.

伴梦长久 2024-07-23 17:10:19

.NET 中 Applet 的对应对象是 ActiveX 控件。 Silverlight 适用于 RIA,类似于 Adob​​e Flash 运行时。

Servlet 可以与 ASP.NET 页面进行比较。 有关它们如何进行端到端比较,请阅读 MSDN 上的以下文章,http: //msdn.microsoft.com/en-us/library/aa478987.aspx

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

回眸一遍 2024-07-23 17:10:19

如果您尝试做一个演示,并且想要展示 .NET 和 servlet/applet 之间的一些相似之处,那么您可以这样做:
1)Servlet演示:
创建一个直接转到代码隐藏类的 .aspx 文件。
使用浏览器调用 .aspx 文件并让代码隐藏类做出响应。

我使用 servlet 作为与 javascript ajax 调用进行频繁通信的方式,并且在行为方面没有任何区别,我的 javascript 函数不知道它正在与什么语言或技术进行通信。

2)小程序演示:
这个有点棘手,因为 Silverlight 的设计似乎是为了与 Flash 竞争,但你可以制作一个时钟小部件并将其放在网页上,然后你可以解释说,通过一些好的设计,两者都可以在 Flash 之外运行浏览器也是如此。

如果能用两种语言进行演示,只是为了进行比较,以表明解决问题的方法有多种,并且在使用哪种技术时需要权衡,那就太好了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文