Pages

Showing posts with label web programming guide. Show all posts
Showing posts with label web programming guide. Show all posts

Thursday, September 12, 2013

Guide to advantages of .Net Framework

1.        What are the advantages of using .NET ?
Consistent Programming Model:
Different programming languages have different approaches for doing a task. For example, accessing data with a VB application and a VC++ application is totally different. A developer has to know bothdifferent techniques to do the task. In case of .NET Environment, for the same example, displaying data from database in a grid accessing data with a VB.NET and a C# is very similar except slight syntactical differences. Both the programs use the System.Data namespace, establish a connection with the database and run a query and displays the data on a data grid.

Language Independence:
Language Independence means the developer has the independence to code one module of an application in one language and other module of same application in other language. This language interoperability can help in code reuse and improve the efficiency of the development process.

No versioning Problem - Easy Application Deployment and Maintenance:
The .NET Framework makes deployment of applications easy. Commonly, to install an application all we need to do is, copy the application along with the components it requires into a directory on the computer. The .NET handles the details of locating and loading the components an application needs, even if several versions of the same application exist on the computer. The .NET ensures that all the components the application depends on are available on the computer before the application begins to run.

Improved Security:
The .NET Framework provides several mechanisms for protecting resources and code from unauthorized users:
·            ASP.NET Web Application Security provides a way to control access to a web site by comparing authenticated permissions with File System permissions for proper authorization.
·            Code access security uses permissions to control the code accessing protected resources and operations. The computer systems are protected from suspicious mobile code and provide a way to run mobile code to safely.
·            Role-based security provides information needed to make decisions about user’s permissions.

Support for Web Services:
Web services are remote databases and programs, which access other computers to read the data files. Web services provide many built in Base Class library facilities which open up a whole new world of information for users.

Dynamic Web:
Content that changes with the user and user preferences is an example of dynamic web content. Dynamic web content is easier to create with .NET. ASP.NET and Visual Studio.NET allow developers to create dynamic web much easier than IIS and ASP technologies.

Visual Studio.NET:

Visual Studio.NET is the Microsoft application and interface for programming in .NET. Visual Studio .NET provides all the programming advantages mentioned so far. This development environment has extensive set of ready to use controls, good debugging facilities, easy and simple programming features and vast set of .NET Base Classes.


1.        Explain different features of .NET.

2.        What is .NET ?
List the advantage of .NET frame work.

Consistent Programming Model:
Different programming languages have different approaches for doing a task. For example, accessing data with a VB application and a VC++ application is totally different. A developer has to know bothdifferent techniques to do the task. In case of .NET Environment, for the same example, displaying data from database in a grid accessing data with a VB.NET and a C# is very similar except slight syntactical differences. Both the programs use the System.Data namespace, establish a connection with the database and run a query and displays the data on a data grid.

Language Independence:
Language Independence means the developer has the independence to code one module of an application in one language and other module of same application in other language. This language interoperability can help in code reuse and improve the efficiency of the development process.

No versioning Problem - Easy Application Deployment and Maintenance:
The .NET Framework makes deployment of applications easy. Commonly, to install an application all we need to do is, copy the application along with the components it requires into a directory on the computer. The .NET handles the details of locating and loading the components an application needs, even if several versions of the same application exist on the computer. The .NET ensures that all the components the application depends on are available on the computer before the application begins to run.

Improved Security:
The .NET Framework provides several mechanisms for protecting resources and code from unauthorized users:
ASP.NET Web Application Security provides a way to control access to a web site by comparing authenticated permissions with File System permissions for proper authorization
·             Code access security uses permissions to control the code accessing protected resources and operations. The computer systems are protected from suspicious mobile code and provide a way to run mobile code to safely.
·             Role-based security provides information needed to make decisions about user’s permissions.

Support for Web Services:
Web services are remote databases and programs, which access other computers to read the data files. Web services provide many built in Base Class library facilities which open up a whole new world of information for users.

Dynamic Web:
Content that changes with the user and user preferences is an example of dynamic web content. Dynamic web content is easier to create with .NET. ASP.NET and Visual Studio.NET allow developers to create dynamic web much easier than IIS and ASP technologies.

Visual Studio.NET:

Visual Studio.NET is the Microsoft application and interface for programming in .NET. Visual Studio .NET provides all the programming advantages mentioned so far. This development environment has extensive set of ready to use controls, good debugging facilities, easy and simple programming features and vast set of .NET Base Classes.

1.        Explain .NET framework?
The .NET Framework is the foundation on which you can design, develop, and deploy applications. It is the core of the .NET infrastructure. It exists as a layer between the .NET applications and the underlying operating system. The .NET Framework encapsulates much of the basic functionality, such as debugging and security services, which was earlier built into various programming languages.

2.        What is unsafe code? Explain.

Unsafe code refers to the code that is processed with low security levels. There are situations where access to pointer types becomes a necessity. For example, interfacing with the underlying operating system, accessing a memory-mapped device, or implementing a time-critical algorithm may not be possible without access to pointers. To address this need, C# provides the ability to write unsafe code. In unsafe code, it is possible to declare and operate on pointers, to perform conversions between pointers and integral types, to take the address of variables, and so forth. In a sense, it is like writing C code within a C# program. Unsafe code must be clearly marked with the modifier unsafe, so developers cannot possibly use unsafe features accidentally. When CLR finds this unsafe modifier, the execution engine works to ensure that the unsafe code cannot be executed in an untrusted environment.

3.        Explain the following:

b) JIT compiler.
JIT compilation converts IL into its native machine code. The name JIT is because it compiles portion of code as and when required at runtime.



4.        How .NET remoting different from web services and DCOM ?
The differences between .NET Remoting and Web services are listed as follows:
·             ASP.NET based Web services can only be accessed over HTTP, whereas the .NET Remoting can be used across any protocol.
·             Web services work in a stateless environment where each request results in a new object created to service the request. .NET Remoting supports state management options and can identify multiple calls from the same client.
·             Web services serialize objects through XML contained in the SOAP messages and can thus only handle items that can be fully expressed in XML. .NET Remoting relies on the existence of the metadata within assemblies that contain information about data types. This limited metadata information is passed about an object, when it is passed by reference.
·             Web services support interoperability across platforms and are good for heterogeneous environments. .NET Remoting requires the clients to be by built using .NET, which means a homogeneous environment.
The difference between .NET Remoting and DCOM is listed as follows:
·             DCOM relies on a proprietary binary protocol that not all object models support. It also wants to communicate over a range of ports that are typically blocked by firewalls. However, .NET Remoting supports different transport protocol formats and communication protocols. This allows .NET Remoting to be adaptable to the network environment in which it is being used.
1.        Write a program in C# to display “Welcome to C Sharp”. Explain the program.
The C# program is as follows:
using System;
namespace ConsoleApplication1
{
class Welcome
{
                             static void Main()
                             {
                             System.Console.WriteLine("Welcome to C Sharp");
                             Console.Read();
}
}
}

The important points to be noted in this program are:
·             Main method: Program execution begins with the Main method.
·             Input and output: The WriteLine function displays the string on the standard output device.
·             Compilation and execution: To compile the program, enter the following command:
cscWelcome.cs
To execute the program, enter the following command:
Welcome

2.        How does C# supports multiple inheritance?
C# directly does not support multiple inheritance. But we can use this feature by using interface. Interface supports multiple inheritance.
interfaceIControl
{
void Paint();
}

interfaceITextBox: IControl //ITextBox inherits IControl
{
voidSetText(string text);
}

interfaceIListBox: IControl //IListBox inherits IControl
{
voidSetItems(string[] items);
}

interfaceIComboBox: ITextBox, IListBox {}
the interface IComboBox inherits from both ITextBox and IListBox. Classes and structs can implementmultiple interfaces.
1.        Define the following :
CLR, CTS, CLS, Intermediate language.
CLR:The CLR loads and executes the code. Code management is a fundamental principle of the runtime. It also provides services such as memory management, thread management, remoting, type safety, code security, and robustness.
CTS:The CTS is a standardized set of basic data types. This system provides a way to language interoperability. An object implemented in one .NET supported language can call an object implemented in another .NET supported language.
CLS: Common Language Specification (CLS) is a set of rules for basic language features that have been defined to enhance and ensure language interoperability.




2.        Give the classification of comman data type system.

3.        What is the function of CTS ? Explain the classification of types in CTS with a diagram.
The CTS defines how types are declared, used, and managed in the runtime. It is important for language interoperability. The CTS performs the following functions:
·             Establishes a common framework that enables cross-language integration, type safety, and high performance code execution.
·             Provides an object-oriented model.
·             Defines rules that languages must follow, so that different languages can interact with each other
CTS can be classified into:
·             Value types
·             Reference types
The following diagram illustrates type classification.
Value types directly store data in the variable. Value types can be built-in type, user-defined types, or enumerations.
Reference types store a reference to the data's memory address. Reference types can be self-describing types, pointer types, or interface types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.
All types derive from the System.Object base type


4.        What is operator overloading? Explain with an example.
Operator overloading refers to loading an operator to perform different operations on different data types on different contexts. To overload an operator in a class, one defines a method by using the 'operator' keyword.
The following program uses operator overloading to create a complex number class ComplexAdd that defines complex addition. The program displays the imaginary and the real parts of the numbers and the addition result using an override of the ToString method.
// complexAdd.cs
using System;
public struct ComplexAdd
{
public int r;
public int img;
public Complex(int r, int img)
   {
      this.r = r;
      this.img = img;
   }
   // Declare which operator to overload
public static ComplexAdd operator +(ComplexAdd c1, ComplexAdd c2)
   {
return new ComplexAdd(c1.r + c2.r, c1.img + c2.img);}
   // Override the ToString method to display a complex number in a required format:
public override string ToString()
   {
return(String.Format("{0} + {1}i", r, img));}
public static void Main()
   {
      ComplexAdd var1 = new ComplexAdd(5,3);
      Complex var2 = new Complex(6,2);
      // Add two Complex objects (var1 and var2) through the
      // overloaded plus operator:
      ComplexAdd total = var1 + var2;
     // Print the numbers and the sum using the overridden ToString method:
Console.WriteLine("First complex number:  {0}",var1);
Console.WriteLine("Second complex number: {0}",var2);
Console.WriteLine("The sum of the two numbers: {0}",total);}}
Output
First complex number: 5 + 3i
Second complex number: 6 + 2i
The sum of the two numbers: 11 + 5i 

Monday, September 9, 2013

Introduction to Web Programming

1Differentiate between Java & Java scripts.
Java :-
Java Programming language, is an OOP Language and development environment, application environment, deployment environment. It is  standalone programming Language that do not require a web browser to execute.
Java script:
It is a contained in the HTML source of webpage. It controls document appearance and content.
It also manipulates embedded images and it also interacts with Applets. Its advantage is that it is simplified,

it doesn’t have to be compiled and the source code resides within our HTML document.

1 What are cookies? And why are cookies used for?
Cookies are small text strings you store on a user's computer. Cookies store information for tracking users in  name-value pairs. When you first visit a website it may store a cookie on your computer. Next, when you again visit the site it may read or manipulate the value of the cookie and perform an action based on it. For example, if a site allows you to customize the color of the user interface, it may set the color selected by you in a cookie on your computer and read the color value when next time you request the page of the website. The page can them be displayed in the color stored in the cookie.

2What is XML? Give the XML document.
XML is a simple, common format for representing structured information as text. You can create your own tags to define and structure data, and transmit it.  The basic syntax of XML is extremely simple. As with HTML, XML represents information as text using tags to add structure. A tag begins with a name in between angular brackets (<>). In XML, every tag must have a closing tag. An opening tag, closing tag and any content in between are collectively referred to as an element of an XML document. Elements can contain other elements but they must be properly nested. Elements can also contain text or a combination of elements and text.

Tuesday, September 3, 2013

Complete Guide to Web Programming - Step 1

What are text nodes?
If a node contains text, it is represented as a text node. For example, in<p id-node2>"This is the <b>initial</b>text.</p>, there are text nodes "This is the", "initial", and "text".

 What is CGI? Give examples of CGI application.
Common Gateway Interface is a specification, which allows Web users to run programs from their computers. CGI is not a programming language but rather a specification that allows programs and scripts written in other language to be run over the Internet.

What is Query String?
QUERY_STRING:The query information passed to the program. It is appended to the URL with a ?when the browser sends it to the server. The name value pairs are then stored in this environment variable.

 What is Extra Path Information?
Besides passing query information to a CGI script, you can also pass additional data known as extra path information as part of the URL. The server gauges where the CGI program name ends; anything following that is deemed as extra path information and stored in the PATH_INFO environment variable. For example the following line calls a script with extra path information:

 What is a web server?
The Web server is the software responsible for accepting browsers' requests, retrieving the specified file or executing the script, and returning its content to the browser. Popular Web servers include Tomcat, Apache, and IIS.

 List out differences between web server and application server.
The main differences between Web servers and application servers are:
A Web server is where Web components are deployed and run. An application server is where components that implement the business logic are deployed. For example, in a JSP-EJB Web application, the JSP pages will be deployed on the Web server whereas the EJB components will be deployed on the application servers.
A Web server usually supports only HTTP (and sometimes SMTP and FTP). However, an application server supports HTTP as well as various other protocols such as SOAP.
In other word
Difference between AppServer and a Web server
(1) Webserver serves pages for viewing in web browser, application server provides exposes business logic for client applications through various protocols
(2) Webserver exclusively handles http requests. Application server serves business logic to application programs through any number of protocols.
(3) Webserver delegation model is fairly simple, when the request comes into the web server, it simply passes the request to the program best able to handle it(Server side program). It may not support transactions and database connection pooling.
(4) Application server is more capable of dynamic behavior than webserver. We can also configure application server to work as a web server.Simplyapplication server is a superset of web server.

1 Describe role of deployment descriptors.
A deployment descriptor is an XML document that defines all the components of an application along with related information such as initialization parameters and container managed security constraints that you want the server to enforce. This file helps the server to know crucial details about the application.

1What is a war file? Give its importance.
WAR or Web Application Archive file is packaged servlet Web application. Servlet applications are usually distributed as a WAR files.
                              WAR file (which stands for "web application archive" ) is a JAR file used to distribute a collection of JavaServer Pages, servlets, Javaclasses, XML files, tag libraries and static Web pages (HTML and related files) that together constitute a Web application.

How to specify session time out in Web.XML?
You can specify session timeout in the <session-timeout> attribute of the <session-config> element. For example, to specify a session timeout of 30 minutes use:
<session-config>
<session-timeout>30</session-timeout>
</session-config>