Pages

Showing posts with label WATD. Show all posts
Showing posts with label WATD. Show all posts

Saturday, April 13, 2013

Difference between Java and JavaScript


      Java is an object oriented programming language whereas JavaScript is more of a scripting language.

        JavaScript is used to make the web pages more interactive. However, Java can be used not only to make interactive web pages but can also be used to create server side applications and standalone programming.

        Java uses the concept of classes and objects that makes reuse of the code easier but there is no such thing in JavaScript.

      Java exhibits the properties like inheritance, data encapsulation and polymorphism whereas JavaScript does not.


Java vs JavaScript

Java and JavaScript are programming languages. Java is an object oriented programming language whereas JavaScript is more of a scripting language. Both can be used to make web pages more interactive. However, Java is also used to develop server side applications and standalone programming.
Java
Java is an object oriented programming language. In early 1990s, Sun Microsystems developed the Java language. Initially, it was designed to make small programs for the web browser called applets. But later on, Java was used to create applications based on e-commerce.
There are five main features of Java language:
• Provides more flexibility to develop software applications because of object oriented approach.
• Easy to use as it combines the best properties of other programming languages.
• Allows code written in Java to run on different platforms or Java code is independent of platform.
• The code from the remote source can be executed securely.
• Built-in support for computer networks.
Java also supports automated memory management model that allows developers to get rid of the time consuming method called manual memory management. Programmers can easily do this by implementing automatic garbage collection. But according to some people, Java is slow as well as consumes more memory than other programming languages such as C++.

JavaScript
JavaScript is also a programming language which is used to make web pages more dynamic as well as interactive. Constant downloads from the server are not required in case of JavaScript as it runs on the user’s computer. JavaScript is different from the Java programming language.
Most modern day web browsers have built-in JavaScript. However, JavaScript based web pages can run only if JavaScript is enabled on the web browser and the browser supports it. JavaScript is enabled in most browsers by default.
No special program is required in order to write code in JavaScript as it is an interpreted language. You can use any text editor such as Notepad in order to write JavaScript code. You can also use other text editor that colorizes the different codes making it easier to detect any error.
JavaScript is different from HTML because JavaScript is used to create more dynamic web pages while HTML is a markup language that is used to create static content on the web page.
You can insert the JavaScript code in a HTML file by using the <script> tag. But if you want to use the script in different pages of the website then you can save the scripts in different files with .js extension.

difference between get and post?

A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of the data to the URL and it will show up in the URL bar of your browser. The amount of information you can send back using a GET is restricted as URLs can only be 1024 characters.

A POST request is a request to post (to send) form data to a resource on the server. 

A POST on the other hand will (typically) send the information through a socket back to the webserver and it won't show up in the URL bar. You can send much more information to the server this way - and it's not restricted to textual data either. It is possible to send files and even binary data such as serialized Java objects!

The GET method appends name/value pairs to the URL. Unfortunately, the length of a URL is limited, so this method only works if there are only a few parameters. The URL could be truncated if the form uses a large number of parameters, or if the parameters contain large amounts of data. Also, parameters passed on the URL are visible in the address field of the browser not the best place for a password to be displayed.

The POST method packages the name/value pairs inside the body of the HTTP request, which makes for a cleaner URL and imposes no size limitations on the forms output. It is also more secure.

what is difference between session and cookies

1. The main difference between cookies and sessions is that cookies are stored in the user's browser, and sessions are not.

2.A cookie can keep information in the user's browser until deleted. But Session work instead like a token allowing access and passing information while the user has their browser open.

3.The difference between sessions and cookies is that a session can hold multiple variables, and you don’t have to set cookies for every variable. By default, the session data is stored in a cookie with an expiry date of zero, which means that the session only remains active as long as the browser. When you close the browser, all the stored information is lost. You can modify this behavior by changing the “session.cookie_lifetime” setting in “php.ini” from zero to whatever you want the cookie lifetime to be.