All java asp.net .net c# servlet jdbc android ado.net clearcase angularjs 2 c nodejs html html5 j2ee

What is a NullPointer Exception in asp.net and how to fix it

Null pointer exception means you are trying to access a member field or a function from an object which is null. for example you created a object of a class object name is "ClassAobj" and you want a variable value from class which is assign and initilize in that class now int a = ClassAobj.Number1; if "ClassAobj" is null then you can not access the value of Number1 . for fixing it ,either you have to initilize the class or you have to full if condition if(ClassAobj != null) { int a = ClassAobj.Number1; }

You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all.

Like anything else, null gets passed around. If it is null in method "A", it could be that method "B" passed a null to method "A".

The rest of this article goes into more detail and shows mistakes that many programmers often make which can lead to a NullReferenceException.

What are the types of cookies?

Cookies can be broadly classified into 2 types

1. Persistent cookies: Remain on the client computer, even after the browser is closed. You can configure how long the cookies remain using the expires property of the Http Cookie object.

2. Non-Persistent cookies: If you don't set the Expires property, then the cookie is called as a Non-Persistent cookie. Non-Persistent cookies only remain in memory until the browser is closed.

There two type of cookies ..
 Persistent cookies: cookies are stored on your computer hard disk. They stay on your hard disk and can be accessed by web servers until they are deleted or have expired. 
public void SetPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;
 cookie.Expires = Convert.ToDateTime(“12/12/2008”);
 Response.Cookies.Add(cookie);}

Non-persistent cookies: cookies are saved only while your web browser is running. They can be used by a web server only until you close your browser. They are not saved on your disk.
 public void SetNonPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;
 Response.Cookies.Add(cookie);}

How do you create a Persistent Cookie?

You create a persistent cookie the same way as session cookies except that you set the Expires property to a Date in the future which will store the Cookie to the client computer hard drive.

//Code to create a UserName Persistent Cookie that lives for 10 days
HttpCookie CookieObject = new HttpCookie("UserName", "David");
CookieObject.Expires = DateTime.Now.AddDays(10);
Response.Cookies.Add(CookieObject);

//Code to read the Cookie created above
Request.Cookies["UserName"].Value;

Cookies have an expiration date implicitly or explicitly set which controls how long they last (subject to the user agent actually enforcing it). A cookie may persist only for the duration of the session (or an even shorter period).

If a cookie is valid, it will be passed along with the HTTP request to the domain that it originated from. Only the domain that set the cookie can read the cookie (though there are ways to exploit this, such as cross-site scripting).

  • If you want a cookie to expire at a specific time, set an expiration date on it using the client or server-side language of your choice.

  • If you want the cookie to expire when the session ends, don't set an expiration date.

Why do we use jQuery?

  • Easy to use and learn.
  • Easily expandable.
  • Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
  • Easy to use for DOM manipulation and traversal.
  • Large pool of built in methods.
  • AJAX Capabilities.
  • Methods for changing or applying CSS, creating animations.
  • Event detection and handling.
  • Tons of plug-ins for all kind of needs.

These are just a few reasons. But the bottom line is the jQuery is becoming the standard for DOM manipulation, simple effects, and much more.

  • Well maintained - Documentation, examples, it's all there.
  • Browser compatible - You don't worry about it.
  • Easy to learn - Spend more time coding!
  • Large community - The answer is always on Stack Overflow.
  • It's correct - It does a lot of small things correctly so you don't have to.
  • Extendable - Tons of community plugins for value.

Why Constructor name is same as Class name

Constructor is called immediately after an object of a class is created. To reduce the number of keywords in Java, name of the constructor is defined same as the Class name. The Java developers don't want to include new keyword for constructor. They want to keep it simple and precise.
So that it can be unambigously identified as the constructor. and how its get invoked implicitly when we create object of that class. It is invoked by the compiler because it has already been unambiguously identified because of its naming sheme.

Rest API Authentication in Java

In token-based authentication, the client exchanges hard credentials (such as username and password) for a piece of data called token. Instead of sending the hard credentials in every request, the client will send the token to the server to perform authentication and authorization.

 in this RESTful services tutorial, we will see about how to do HTTP basic authentication. There are many ways to implement authentication in RESTful web services. HTTP basic authentication is the first step in learning security.

http://javapapers.com/web-service/restful-services-http-basic-authentication/

Advantages of Rational ClearCase over other SCM tool i.e Microsoft Visual Source Safe

1. In ClearCase Check-in's are atomic.
2. Directories are first-class controlled entities in 
Clearcase. Even supports controlling of symbolic/hard links.

As with the ClearCase Bridge, you are continuing to use ClearCase for versioning, and are using RTC for change request management, task management, and planning.   With the Clearcase importer (either the Version Importer or the Baseline Importer), you are using RTC for versioning as well, and only using Clearcase for occasional access to archived versioned information that was not imported into RTC. In Clearcase performance is better supports more data size.


VSS Performance is poor and supports less data size.Directories are first-class controlled entities in clearcase. Even supports controlling of symbolic/hard links and The multisite is the best part of clearcase than any other 
tool.

In CLearcase performance is better supports more data size..

VSS Performance is poor and supports less data size.....

Explain servlet life cycle.

A servlet life cycle can be defined as the entire process from its creation till the destruction. The following are the paths followed by a servlet.

  • The servlet is initialized by calling the init () method.
  • The servlet calls service() method to process a client's request.
  • The servlet is terminated by calling the destroy() method.
  • Finally, servlet is garbage collected by the garbage collector of the JVM.
The web container maintains the life cycle of a servlet instance. Let's see the life cycle of the servlet:
  1. Servlet class is loaded.
  2. Servlet instance is created.
  3. init method is invoked.
  4. service method is invoked.
  5. destroy method is invoked
there are three states of a servlet: new, ready and end. The servlet is in new state if servlet instance is created. After invoking the init() method, Servlet comes in the ready state. In the ready state, servlet performs all the tasks. When the web container invokes the destroy() method, it shifts to the end state.

1) Servlet class is loaded

The classloader is responsible to load the servlet class. The servlet class is loaded when the first request for the servlet is received by the web container.

2) Servlet instance is created

The web container creates the instance of a servlet after loading the servlet class. The servlet instance is created only once in the servlet life cycle.

3) init method is invoked
The web container calls the init method only once after creating the servlet instance. The init method is used to initialize the servlet. It is the life cycle method of the javax.servlet.Servlet interface. Syntax of the init method is given below:
  1. public void init(ServletConfig config) throws ServletException  
 

4) service method is invoked

The web container calls the service method each time when request for the servlet is received. If servlet is not initialized, it follows the first three steps as described above then calls the service method. If servlet is initialized, it calls the service method. Notice that servlet is initialized only once. The syntax of the service method of the Servlet interface is given below:
  1. public void service(ServletRequest request, ServletResponse response)   
  2.   throws ServletException, IOException  
 

5) destroy method is invoked

The web container calls the destroy method before removing the servlet instance from the service. It gives the servlet an opportunity to clean up any resource for example memory, thread etc. The syntax of the destroy method of the Servlet interface is given below:
  1. public void destroy()  
 
  1. Loading Servlet Class : A Servlet class is loaded when first request for the servlet is received by the Web Container.
  2. Servlet instance creation :After the Servlet class is loaded, Web Container creates the instance of it. Servlet instance is created only once in the life cycle.
  3. Call to the init() method : init() method is called by the Web Container on servlet instance to initialize the servlet.

    Signature of init() method :

    public void init(ServletConfig config) throws ServletException
    
  4. Call to the service() method : The containers call the service() method each time the request for servlet is received. The service() method will then call the doGet() or doPost() methos based ont eh type of the HTTP request, as explained in previous lessons.

    Signature of service() method :

    public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
    
  5. Call to destroy() method: The Web Container call the destroy() method before removing servlet instance, giving it a chance for cleanup activity.

why you used JavaScript? Can it use for both client side and server side validation purpose?

Javascript is a client side scripting, which runs in the browser. Even AJAX runs in the browser and is also a client 
side one, which actually is nothing but Javascript. In AJAX javascript is used to communicate with server side 
components or post values to a JSP / ASP or any web page or any services which can be referred by URL.

JavaScript is a platform-independent,event-driven, interpreted client-side scripting and programming language. 

Javascript (ECMA script) when executed in the browser context makes it client side, if you are using it for creating API's etc with nodeJS you get to use it on the server side 

Client-side validation just avoids the client from going "but I filled this all in and it didn't tell me anything!". It's not actually mandatory, and in reality, client-side validation is a very new thing (read: 5 years old or less). In practice, all it does is prevent your client (with JS enabled) to know whether the form is okay before reloading a page. If AJAX is in the game, it is different - it allows you to save bandwidth as well as to provide user with feedback before submission. Finally, if you're building strictly client-side, peer-to-peer exchange apps (think games), you'll want client-side validation to keep the clients from cheating.

Server-side validation is also crucial due to the fact that client-side validation can be completely bypassed by turning off JavaScript. In a way, JS-driven validation is a convenience and an aesthetic/cosmetic improvement and should not be relied upon. Furthermore, it is trivial to edit the source of a page locally in order to disable or bypass even the most complex of JS validation.

What could a user do if you do not server-side validate? Anything, depending on how you use their data. You could be allowing users to drop entire databases (or worse, leak them), modify anything they like (or worse, read anything they like. Directory traversal flaws are extremely common entrance points for naughty people), and elevate their privileges at will. Do you want to run this risk? Not validating user input is like trusting people and not installing locks on your house.

The main use of Javascript is that it allows you to make things happen in the user's browser without sending messages back and forth to the server. There are a variety of reasons why you might want to do this.

For example, sending a message to the server and getting a reply is a relatively long process: it is almost always a noticable time lag, and can take many seconds. Doing something directly in the browser can be much faster. So if, for example, you want to give the user an "invalid data" message of some sort, it can be much faster if it comes from Javascript.

In the same vein, with Javascript you can validate field-by-field rather than waiting until the user has completely filled out the screen and clicked a submit button. For example, suppose you present the user with a screen where he's supposed to enter transaction dates and monetary amounts. The user enters a whole screen full of these -- maybe 20 or 30 transactions -- and then clicks submit. If the user attempts to type dates in a format that you don't recognize, say typing day/month/year when you expected year-month-day, then with Javascript you could give him an error on the first unrecognizable date. With a round trip to the server, he'd have typed in a whole screen-full of invalid dates before you tell him he's doing it wrong.

What are the advantages of automation testing?

  • It supports execution of repeated test cases.
  • It facilitates parallel execution.
  • It aids in testing a large test matrix.
  • It improves accuracy because there are no chances of human errors.
  • It saves time and money.

Benefits of automated testing

  • ROI.

Let’s start from the beginning: the big initial investment. This may be a hold back for many, but it is proven that the return of that investment is a long-term one and it will also save time.

ROI - benefits of automated testing

  • Running tests 24/7:

No matter where you are in the world. You can start the tests when you leave the office and when you get back in the morning you can see the results and keep on working. You can even do that remotely if you don’t have a lot of devices or you don’t have the possibility to buy them.

  • Fewer human resources.

You don’t need a lot of people: you would need a test automation engineer to write your scripts to automate your tests, instead of a lot of people doing boring manual tests over and over again.

  • Reusability.

The scripts are reusable:

  • you don’t need new scripts all the time, even if the version of the OS on the device changes
  • it allows you to redo the test exactly the same, without forgetting any steps
  • Bugs.

Automation helps you find bugs in the early stages of software development, reducing expenses and working hours to fix these problems as well.

  • Reliability:

automated testing is more reliable and way quicker when running boring repetitive standardized tests which can not be skipped, ever, but may cause errors when manually tested

  • Simultaneity:

you can test more devices simultaneously resulting in comparative detailed reports generated in less time with the exact the same parameters, because the exact same scripts were run.

  • Continuity:

automated testing helps testers, such as automation engineers. They can see exactly what other engineers have done, what scripts he has already written and what tests have already been performed and what bugs were already found and fixed, through clear reports.

  • Additional methods:

one of the these methods is the stress test in which the capacities of the application and operational infrastructure will be tested to it’s limits with stress test, which can’t be done manually.

  • Volume:

automated testing allows to run tests on thousands of mobile devices (more then 18000 devices). Testing all of them manually would be impossible!

In the end you will have a better quality software which will be released earlier, with less problems and you have used less resources.

As largely know, there is usually always a downside to everything. So there are downsides to automated testing as well.

There are a few things that automated testing won’t do: it won’t fix specific problems that users might have. When writing and testing the scripts there are just some scenarios that are being tested, not all of them. The main purpose of automated testing is to find bugs in simple operations, e.g. to log into the app, create a new account or send email when the password gets forgotten. That’s what automated tests do.

Test automation can automate some repetitive but necessary tasks in a formalized testing process already in place ,or perform additional testing that would be difficult to do manullay. A growing trend soft ware development is the use of testing frameworks such as the xunit frame work. example : junit runs tests significantly faster than human users. how the website software reacts after repeated execution of the same operation. test can be used re used on different versions of the software. The same operation each time they are run thereby eliminating humman error. Testers can program sophisticated tests that bring hidden information.
  • Reduced test execution time
  • Can be executed in cross platforms test cases (different OS, browsers, environment, etc)
  • Simplifies complex functional tests
  • Automating repetitive tasks
  • Enables parallel execution