Compare .Net with J2EE(.net与J2EE的联系与区别)

First of all, I want to give a conclusion: .Net and J2ee are the same in the rock-bottom implement.. That's because both of them are web pages, which must follow the process of web page--sending request, receiving request, process request and return the html. However, .Net make an encapsulation of the original web proecss and make it more like a webForm process and make programming easier.

 

 

1.   .cs Files behind every .aspx page connected by the runat=”server” tag

 

A few years ago, the jsp technology provides us to write our code inside the Html page. It is a great innovation. After that, we put our logical code into a single asp file and display another jsp file in which we forward the request into this logical jsp file when a form is submit. But since the logical code is to hand with the prior jsp file why not to put them together in the same class. Base on that consideration, Microsoft creates the asp.net mode. Meanwhile in order to separate the html page and the code page, Microsoft decides to use two pages by using the keyword of partial. But how the .cs file code can interact the html file, to make it easier, MS offer us one way that every html tag which we want to get value from, are added the attribute of “runat =’server’ ” , so that the .cs class can communicate with the html file. In fact, they are compiled the same class. Of course, the inner mechanism is implemented by MS.

 

 

Let’s look back, why MS provide this kind of mechanism to build a web page? And what it can bring to us? The answer is to improve the efficiency of building a web project and make it easy to program. Personally, I think it is good and this gives us more time to think about the business logic.

 

Comparing to .Net’s convenience, J2EE find its weakness. Then lots of grant architect want to make J2EE as easy to build as .Net, so they build up the framework such like Struts and hibernate and so on. Personally, I think the ActionForm and Action is to make up J2EE platform’s inadequacies. J2EE is trying studying the idea of .Net. Even so, I think there are also some idea that .Net should learn, like looser coupling by using the xml file.

 

 

 

2.  Use postback mechanism and use ViewState to transfer binding data.

 

The tradition web is stateless and disconnect. So when you fresh a page, the data you write on the preview page is lost. .Net offers us a post back mechanism and save the information automotive by its framework. .Net platform uses ViewState to store the postback information. Every request the information inside the ViewState is different and through this way we can deliver the information between different requests in the same page.

 

 

ViewState is used to track and restore the state values of controls that would otherwise be lost, either because those values do not post with the form or because they are not in the page html. This means that a control totally defined in your page html, with no changes made in the code, will have no ViewState at all, as is often the case when using drag-n-drop with static content. Instead, ViewState only holds the values of properties that are dynamically changed somehow, usually in code, data-binding, or user interactions, so that they can be restored on each request.

 

So, ViewState holds properties you change in code, any data that you bind to a control in code, and any changes that occur as a result of user interactions that were triggered with a PostBack. An example of a user interaction is a user selecting a date or moving a month in the calendar, which triggers a PostBack that changes properties of the calendar to match the users request. The new date selected or month being viewed must be persisted in the calendars ViewState since these are properties that will need to be restored but which will not be posted next time.

 

 

3.   The powerful control library, especially the data and customer controls.

 

On one hand, it can help me us to access the database and reduce our code.

On the other thing, it offers us a method to reuse our component.

Meanwhile, .Net support us to develop customer controls.

 

Above all, I think just the top three mainly innovation, makes the asp.net platform more powerful.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值