Witshaper is the Professional (Computing Skills, English Learning and Soft Skills) Skill Development Training Center. We provide Professional IT Courses and Soft Skill Training in Dehradun to Students, Employees and organization. Who wish to pursue a career in IT Technology. Witshaper is led by a motivated team of IT experts and Soft Skill Professionals. We provide high quality trainings. Our Emphasis is on giving the practical knowledge to the students, so that they will get to know in depth and never forget what they opt, we provide to the students real learning environment. Witshaper prepares students and professionals to be the part of this growing industry. Be a part of Witshaper and get your dreams successful

Wednesday 4 November 2015

Introduction to servelets

What is a Servlet?
Servlets provide a component-based, platform-independent method for building Web-based applications, without the performance limitations of CGI programs. Servlets have access to the entire family of Java APIs, including the JDBC API to access enterprise databases.
Servlet technology is used to create web application (resides at server side and generates dynamic web page).
Servlet technology is robust and scalable because of java language. Before Servlet, CGI (Common Gateway Interface) scripting language was popular as a server-side programming language. But there was many disadvantages of this technology.

What is web application ? :  A web application is an application accessible from the web. A web application is composed of web components like Servlet, JSP, Filter etc. and other components such as HTML. The web components typically execute in Web Server and respond to HTTP request.

Friday 3 July 2015

ssh and telnet (difference )implementation





Telnet
The Telnet protocol is still broadly used but on the other hand it is valuable remembering  that it is not as secure as SSH; therefore in any situation in the real world where security is of major concern at that time SSH should always be used.
Below is the basic primary configuration of the router:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#hostname R1

R1(config)#enable secret cisco

R1(config)#int f0/0
R1(config-if)#ip address 192.168.0.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#ex

R1(config)#line vty 0
R1(config-line)#password cisco
R1(config-line)#login
R1(config-line)#exec-timeout 30
R1(config-line)#logging synchronous
R1(config-line)#motd-banner
R1(config-line)#exit

R1(config)#do copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
R1(config)#

1) elected to have only a single line (hence the line vty 0); if you want more lines then the command would read something like: line vty 0 4 - this would give me a total of 5 lines (lines 0 through 4).
2) The exec-timeout command just sets the time-out limit on the line from the default to 30 minutes. The shorter time-out can be annoying when configuring several devices at once.
3) The logging synchronous command stops any message output from splitting your typing
 4) the motd-banner forces a banner message to appear when logging in. 

SSH
Configuring SSH is identical to Telnet. The key difference is the generation of the crypto key; the basic line parameters are the same:

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#hostname R2

R2(config)#enable secret cisco

R2(config)#int f0/0
R2(config-if)#ip address 192.168.10.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#ex

R2(config)#ip domain-name steve.local

R2(config)#crypto key generate rsa
The name for the keys will be: R2.steve.local
Choose the size of the key modulus in the range of 360 to 2048 for your
  General Purpose Keys. Choosing a key modulus greater than 512 may take
  a few minutes.

How many bits in the modulus [512]: 512
% Generating 512 bit RSA keys, keys will be non-exportable...[OK]

R2(config)#ip ssh time-out 30

R2(config)#ip ssh authentication-retries 5

R2(config)#line vty 0
R2(config-line)#transport input ssh
R2(config-line)#login
% Login disabled on line 66, until 'password' is set
R2(config-line)#password cisco
R2(config-line)#logging synchronous
R2(config-line)#motd-banner
R2(config-line)#exit

Domain name and  the hostname; these two variables will form the basis of the key generation.therefor these variable are important to form 



after executing 

R2(config)#username steve password tiddles

R2(config)#line vty 0
R2(config-line)#login local
R2(config-line)#exit

virtual private network implementation




Configuration for tunnel security or VPN 

hostname Left
!
!
!
!
!
!
!
!
crypto isakmp policy 5
encr 3des
authentication pre-share
group 2
lifetime 72000
!
crypto isakmp key cisco address 10.0.0.2
!
!
crypto ipsec transform-set STRONG esp-3des esp-sha-hmac
!
crypto map CISCO 10 ipsec-isakmp
set peer 10.0.0.2
set pfs group2
set transform-set STRONG
match address 101
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
ip address 10.0.0.1 255.255.255.0
duplex auto
speed auto
crypto map CISCO
!
interface FastEthernet0/1
ip address 192.168.0.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 0.0.0.0 0.0.0.0 10.0.0.0
ip route 192.168.2.0 255.255.255.0 10.0.0.0
!
!
access-list 101 permit ip 192.168.0.0 0.0.0.255 192.168.2.0 0.0.0.255
!
!
!
!
!
line con 0
line vty 0 4
login
!
!
!
end

And the Second Configuration :
hostname Right!
!
!
!
!
!
!
!
crypto isakmp policy 5
encr 3des
authentication pre-share
group 2
lifetime 72000
!
crypto isakmp key cisco address 10.0.0.1
!
!
crypto ipsec transform-set STRONG esp-3des esp-sha-hmac
!
crypto map Cisco 10 ipsec-isakmp
set peer 10.0.0.1
set pfs group2
set transform-set STRONG
match address 101
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
ip address 10.0.0.2 255.255.255.0
duplex auto
speed auto
crypto map Cisco
!
interface FastEthernet0/1
ip address 192.168.2.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 0.0.0.0 0.0.0.0 10.0.0.0
ip route 192.168.0.0 255.255.255.0 10.0.0.0
!
!
access-list 101 permit ip 192.168.2.0 0.0.0.255 192.168.0.0 0.0.0.255
!
!
!
!
!
line con 0
line vty 0 4
login
!
!
!

end

Thursday 2 July 2015

switch port security configuration implementation





Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-sec
Switch(config-if)#switchport port-security

Switch(config-if)#switchport port-security mac-address 0001.C70C.0D7D
Switch(config-if)#switchport port-security violation ?
Switch(config-if)#switchport port-security violation shutdown

Wednesday 20 May 2015

java program to create thread and set priority ,id,and name

import java.lang.*;

public class ThreadDemo  {

   public static void main(String[] args)  {

Thread t1 = Thread.currentThread();
Thread t2 = Thread.currentThread();
Thread t3 = Thread.currentThread();
Thread t4 = Thread.currentThread();
Thread t5 = Thread.currentThread();
        t1.setName("My Thread1");
    t2.setName("My Thread2");
    t3.setName("My Thread3");
    t4.setName("My Thread4");
    t5.setName("My Thread5");   
    
     t1.setPriority(6);
     t2.setPriority(6);
     t3.setPriority(6);
     t4.setPriority(6);
     t5.setPriority(7);
try
{      
     t3.sleep(2000);
    t5.sleep(2000);
}
catch(Exception ex)
{
System.out.println("exception caught is"+ex);
}
        System.out.println("Thread = " + t1);
    System.out.println("Thread = " + t2);
    System.out.println("Thread = " + t3);
    System.out.println("Thread = " + t4);
    System.out.println("Thread = " + t5);
     int count = Thread.activeCount();
     System.out.println("currently active threads = " + count);
   }
}

Write a Java program to enable the user to handle any chance of divide by zero exception

import java.io.*;
import java.util.*;
class Numz
{
public static void main(String args[])
{
   int i=0,a;
float r;
System.out.println("Enter the number to divide 100:");
Scanner in=new Scanner(System.in);
a=in.nextInt();
try
{
if(a==0)
{System.out.println("Program Terminated Exception Caught");
throw new Exception();
}
if(a!=0)
{
r=100/a;
System.out.println("Result is:"+r);
}
}
catch(Exception e)
{
System.out.println("Exception Caught is Divide By Zero");
}
}
}

Write a java program to throw a exception (checked) for an employee details. If an employee name is a number, a name exception must be thrown. If an employee age is greater than 50, an age exception must be thrown. or else an object must be created for the entered employee details

import java.io.*;
import java.util.*;
class Numx
{
public static void main(String args[])
 {
String name;
int age;
System.out.println("-----ENTER EMPLOYEE DETAILS-----");
System.out.println("Enter Name and Age:");
Scanner in=new Scanner(System.in);

try
{
if(!(in.nextLine().matches("[a-zA-Z]+")))
{throw new IOException();}

age=in.nextInt();
if(age>50)
{
System.out.println("Age greater than 50 Exception");
throw new Exception();
}

Numx x=new Numx();
System.out.println("-----Object Created-----");
}

catch(Exception e)
{
System.out.println("Exception");
}
}
}

java example to show ArrayIndexOutOfBoundsExeption

import java.io.*;
import java.util.*;
class Nums
{
 public static void main(String args[])
 {
   int i=0,j=0;
try
{
   String s[]=new String[9];
   int b[]=new int[10];
   System.out.println("Enter the Name of 10 students:");
   Scanner in=new Scanner(System.in);
        for(i=0;i<10;i++)
    {
    s[i]=in.nextLine();
    }
    }
catch(ArrayIndexOutOfBoundsExeption e)
{
System.out.println("Program Not Terminated Exception Caught\n"+e);
String s[]=new String[10];
int b[]=new int[10];
     System.out.println("----CONTINUE----");
    System.out.println("Enter the Name of 10 students:");
        Scanner in=new Scanner(System.in);
        for(i=0;i<10;i++)
    {
    s[i]=in.nextLine();
    }
    System.out.println("Enter the Roll no of 10 students:");
    for(j=0;j<10;j++)
     {
      b[j]=in.nextInt();
       }

    i=j=0;
    System.out.println("Name and Roll No are:");
    while(i<10&&j<10)
    {
     System.out.println(s[i]+"\t"+b[j]);
     i++;j++;
    }
}

}
}

A java class which throws an exception if operand is nonnumeric in calculating modules

import java.io.*;
import java.util.*;
class Numb
{
 public static void main(String args[])
 {
   int i,j;
float add,sub,mul,div;
System.out.println("CALCULATOR:");
System.out.println("Enter two Operands:");
Scanner in=new Scanner(System.in);
try
{
i=in.nextInt();
j=in.nextInt();
add=i+j;
sub=i-j;
mul=i*j;
div=i/j;
System.out.println("Addition ="+add);
System.out.println("Subtraction ="+sub);
System.out.println("Multiplication ="+mul);
System.out.println("Division ="+div);
}

catch(InputMismatchException e)
{
System.out.println("Program Is Terminated Exception Caught");
}

}
}

example in java to show InputMismatchException

import java.util.Scanner;
import java.util.InputMismatchException;

public class Modulus{
public void calMod(double x) throws InputMismatchException{
Scanner inp= new Scanner(System.in);
System.out.println("Enter The Number You want to Calculate the Modulus Of");
x= inp.nextDouble();
if(x<0){
System.out.println("Modulus of |"+x+"| is");
x=-x;
System.out.println(x);
}
else{
System.out.println("Modulus of |"+x+"| is"+x);
}
}

public static void main(String[] args){
double x=0;
Modulus m= new Modulus();
try{
m.calMod(x);
}
catch(InputMismatchException ie){
System.out.println("Exception: The Entered value is not Numeric Type");
}
}
}

java example to throw a new exception if given condition satisfied

import java.util.Scanner;
import java.io.*;
class Employee{
public static void main(String args[]){
String name;
int age;
System.out.println("ENTER EMPLOYEE DETAILS");
System.out.println("Enter Name and Age Of The Employee:");
Scanner in=new Scanner(System.in);

try
{
if(!(in.nextLine().matches("[a-zA-Z]+"))){
throw new IOException("Please Enter The Name in Aplhabets");
}
age=in.nextInt();
if(age>50){
System.out.println("Age greater than 50 Exception");
throw new Exception("You Are Too Old to Work , Take Retirement");
}
Employee x=new Employee();
System.out.println("Object Created");
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
}
}

example to throw ArithmeticException in java

import java.util.Scanner;

public class Divisor{
public static void main(String[] args){
Scanner inp=new Scanner(System.in);
System.out.println("Enter the First number");
double x=inp.nextDouble();
System.out.println("Enter the Second number");
double y=inp.nextDouble();
Divisor d= new Divisor();
d.divide(x,y);
}
public void divide(double x, double y){
double result=0;
try{
if(y==0){
throw new ArithmeticException("Divisor Cannot Be Zero");
}
}
catch(ArithmeticException ae){
System.out.println("Exception:Divisor Cannot be ZERO "+"\n Enter the Divisor again");
Scanner inp=new Scanner(System.in);
y=inp.nextDouble();
}
result=(x/y);
System.out.println("Result of the divsion is "+result);
}
}

arrays and exception example in java

import java.util.Scanner;

public class DisplayRecords {
public static void main(String[] args){
try{
System.out.println("Enter The Roll Numbers of The Students");
int []a=new int[10];
Scanner input=new Scanner(System.in);
for(int i=0;i<10;i++){
a[i]=input.nextInt();
}
System.out.println("Enter The Name Of The Students");
String []s=new String[10];
for(int i=0;i<10;i++){
s[i]=input.nextLine();
}
System.out.println("Entered Roll No for the Students");
for(int i=0;i<10;i++){
System.out.println(a[i]);
}
System.out.println("Entered Name of The Students");
for(int i=0;i<10;i++){
System.out.println(s[i]);
}
}
catch(ArrayIndexOutOfBoundsException ae){
System.out.println("Caught Exception");
}
}
}

java example to throw exception



import java.util.Scanner;

public class Collision{

public static void main(String[] args){
int x=0;
System.out.println("     ONE WAY \nDo Not Take a U Turn");
Scanner inp=new Scanner(System.in);
x=inp.nextInt();
try{
if(x>0){
throw new Exception("Please Stop Immediately In Order To Avoide Collision");
}
else{
System.out.println("Have a Safe Journey");
}
}
catch (Exception ex){
System.out.println(ex.getMessage());
}
}
}

A very simple example to show the concept of interface in java

interface Test{
public void square(int j);
}

class Arithmetic implements Test{
public void square(int j){
int result;
result=(j*j);
System.out.println("Square Of The Integer Is="+result);
}
}

public class ToTestInt{
public static void main(String[] args){
Arithmetic ar=new Arithmetic();
ar.square(12);
}
}

example of interface in java two add two integers

interface A{
public void meth1(int j, int k);
public void meth2(int x, int y, int z);
}

public class MyClass implements A{
int y,x,z;
public void meth1(int j, int k){
int result;
result=(j+k);
System.out.println("Sum Of The Integers is="+result);
}
public void meth2(int x,int y,int z) {
this.x=x;
this.y=y;
this.z=z;
System.out.println("Entered value of Integers is x="+x+" y="+y+" z="+z);
}
public static void main(String[] args){
MyClass mc=new MyClass();
mc.meth1(12,14);
mc.meth2(14,1,5);
}
}

another example of interface in java to show division

interface Test{
public void division(double x, double y);
public void calMod(double x);
}
public class DivMod{
public void division(double x,double y){
double result;
result=(x/y);
System.out.println("Result for Division is="+result);
}
public void calMod(double x){
if(x<0){
System.out.println("Modulus of |"+x+"| is");
x=-x;
System.out.println(x);
}
else{
System.out.println("Modulus of |"+x+"| is"+x);
}
}
public static void main(String[] args){
DivMod dm= new DivMod();
dm.calMod(-12);
dm.division(14,7);
}
}