Sunday 31 January 2016

Use of request.getRequestDispatcher with example

Use of request.getRequestDispatcher 


It is interface. It provides the facility of dispatching the request to another resource it may be html, servlet or jsp.


## Example This example is for you how to use it.

import java.io.*;  
import javax.servlet.*;  
import javax.servlet.http.*;    
public class register extends HttpServlet {  
  
public void doPost(HttpServletRequest request, HttpServletResponse response)  
        throws ServletException, IOException {  
  
    response.setContentType("text/html");  
    PrintWriter out = response.getWriter();  
          
    String n=request.getParameter("userName");  
    String p=request.getParameter("userPass");  
          
    if(p.equals("servlet"){  
        RequestDispatcher rd=request.getRequestDispatcher("servlet2");  
        rd.forward(request, response);  
// here servlet2 is get Dispatcher.
    }  
    else{  
        out.print("Unsucessful!");  
        RequestDispatcher rd=request.getRequestDispatcher("/index.html");  
        rd.include(request, response);  

  }
    }
}

Sunday 17 January 2016

Operators in java with precedence

Many types of operator in java like as :


  1. Postfix operator
  2. Unary operator
  3. Multiplicative operator
  4. Additive operator
  5. Shift operator
  6. Relation operator
  7. Equality operator
  8. Bitwise AND operator
  9. Bitwise exclusive OR operator
  10. Bitwise inclusive OR operator
  11. Logical AND operator
  12. Logical OR operator
  13. Ternary Operator
  14. Assognment operator





Tuesday 12 January 2016

Differents between object and class in java

Object :-
Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical.


Class :-

A class is a prototype that defines the variables and the methods common to all objects of a certain kind.





Saturday 2 January 2016

What is JVM(Java Virtual Machine) in java

The Java Virtual machine (JVM) is the virtual machine that run the Java bytecodes. 





It is a specification that provides runtime environment in which java bytecode can be executed. It is available for many hardware and software platforms.


## It's Performs Following main Tasks :

  1. Loads code
  2. Executes code
  3. Verifies code
  4. Provides returns environment
The java virtual machine provides a platform independent way of executing code; that mean compile once any machine and run it any where.