postheadericon Bit Stuffing - Framing Technics

Sender



#include<stdio.h>
#include<string.h>
#include<fcntl.h>



int getBit(int frameData,int pos)
{
//get binary equavalient of our Frame Data by setting on bit by bit

int code=1; // take base of binary 1 [ 00000001 ]

code=code<<(pos-1); // do the left shift to find  postion

if(frameData & code)  // if both bits are 1 then set bit otherwise return ZERO
return 1;
else
return 0;

}


void bitStuffing(char myFrame[])
{
// stuffing procedure
int i=0,k=0,counter=0;
char temp[50];
strcpy(temp,myFrame);
while(temp[i]!='\0')
{
myFrame[k++]=temp[i]; // update Frame data by doing Stufing
if(temp[i]=='1')
{
// if we encounter continues 1 then do increment in counter
counter++;
}
else
{
// if continuty of 1's break, reset counter to ZERO
counter=0;
}
if(counter==5)
{
// after a FIVE consicutive ONE stuff a bit ZERO
myFrame[k++]='0';
}
i++;
}
myFrame[k]='\0';
}
void main()
{
int pid,i,no,k=0,frameData,frame_size=32;
char myFrame[50];


system(">pipe");


pid=open("pipe",O_WRONLY); // open named pipe for write mode

system("clear");

//Enter Frame Data in decimal Number
printf("\nEnter Frame Data : ");
scanf("%d",&frameData);

for(i=frame_size;i>0;i--)
{
myFrame[k++]=getBit(frameData,i)+48;
}
myFrame[k]='\0';

printf("\nBefore Stuffing Frame : %s",myFrame);

bitStuffing(myFrame); // do the process of bit Stuffing

printf("\nAfter Stuffing  Frame : %s\n\n",myFrame);
write(pid,&myFrame[0],sizeof(myFrame)); //write frame in to named pipe
}

postheadericon Difference between GenericServlet and HttpServlet

GenericServlet:


  • As name says it Generic in nature. Means GenericServlet is protocol-independent.
  • import  javax.servlet.servlet package
  • super class of GenericServlet are java.lang.Object and it implements three interfaces Servlet, ServletConfig and java.io.Serializable
  • To write a generic servlet, override the abstract service().
  • GenericServlet  lifecycle methods use ServletConfig interface.
  • GenericServlet implements the log() from ServletContext interface.
  • Prototype:
    • public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable
  • Example:

postheadericon hello world servlet example

Step 1 :  Create .java File using text editor


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ServletDemo extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML><HEAD><TITLE>WTAD</TITLE></HEAD> <body>");
String str="<h1>welcome to </h1>";
str=str+"<br>www.bipinrupadiya.blogspot.com";
out.println(str);
        out.println("</body> </html>");
}
}

postheadericon Setup Environment Variable for Tomcat



Step : 1 Right Click on My computer and Choose Propertis


    Step : 2 From System Properties Dialog box got to Advance tab and click on Environment Variable Button


    postheadericon install tomcat 7

    This text define How to install Tomcat Application server on windows operating system


    Step : 1 Download Java Development Kit 


    • Servlet required Java Development Kit to compile and Execute  code 
    • Go to http://www.oracle.com and Download latest version of JDK and JRE
    • Install JDK

    Step : 2 Select IDE for the Development of Servlet

    • There so many editor used for J2EE Devlopment like NetBeans, Eclipse, Dreamviewer or Plain Text Editor etc.
    • We use Notpad  as per GTU Guidelines  

    Total Pageviews

    © BipinRupadiya.com. Powered by Blogger.