Where To Use Telnet

Where To Use Telnet

Telnet is used when diagnosing problems is there, manually talk to other services without using specialized client software.

It also used in debugging network services.
For Example SMTP, HTTP, FTP or POP3 server
By serving as to send commands to the server and examine the responses.

How to Start Telnet In Your System:

1) Go to Control Panel And Open Turn Off and On Program Features.
2) Just Check Mark On Telnet Client And Click OK
3) After that you can use the commands of telnet in your command prompt
Much better way for learning

Much better way for learning

Much better ways for learning or teach the students

Do:

  1. Show videos to the student about any topic
  2. Develop the self learning techniques to the student, They will automatic learn how to learn by self.
  3. After no students will dependent to anyone or tutor.
  4. This skill will automatic increase the searching & critical thinking skill
Don't:

  1. Do not try to mug up content
  2. Do not teach what are the things... just teach how things are working.
  3. Teacher's speech volume should be high-low low-high...otherwise same frequency voice may be 
  4. Don't read and explain content from presenetation file (PPT) or any book.
Happy Learning...
Insert, update, delete, and select with Servlet and Access

Insert, update, delete, and select with Servlet and Access

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class index extends HttpServlet
{
Connection con;
PreparedStatement ps;
ResultSet rs;
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();

String roll=request.getParameter("roll");
String name=request.getParameter("name");
String city=request.getParameter("city");

out.println("<form name=f1>");
out.println("Roll:<input name='roll'><br>");
out.println("Name:<input name='name'><br>");
out.println("City:<input name='city'><br>");
out.println("<input type=submit name='Insert' value='Insert'>");
out.println("<input type=submit name='Update' value='Update'>");
out.println("<input type=submit name='Delete' value='Delete'>");
out.println("</form>");

out.println("<table><tr><th>Roll<th>Name<th>City</tr>");
try{
connect();
ps=con.prepareStatement("select * from stud");
rs=ps.executeQuery();
while(rs.next())
{
out.println("<tr><td>"+rs.getString(1)+"");
            out.println("<td>"+rs.getString(2)+"");
out.println("<td>"+rs.getString(3)+"</tr>");
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
out.println("</table>");

if(request.getParameter("Insert")!=null)
putData("insert into Stud values('"+roll+"','"+name+"','"+city+"')");
if(request.getParameter("Update")!=null)
putData("update Stud set name='"+name+"',city='"+city+"' where roll='"+roll+"'");
if(request.getParameter("Delete")!=null)
putData("delete from Stud where roll='"+roll+"'");
}

public void connect()
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MyDb");
}
catch(Exception e){
System.out.println(e);
}
}

//single method to insert, update, delete
public void putData(String query)
{
try{
connect();
ps=con.prepareStatement(query);
ps.executeUpdate();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Insert, update , delete inside a single function... with jsp & access....

Insert, update , delete inside a single function... with jsp & access....

//JDBC program with jsp ( makes easy to data manipulation )
//Insert, update , delete inside a single function... with jsp & access....


<html>
<body>
<form method=post>
<table>
    <tr>
        <td>Enter Roll No:
        <td><input type=text name=no>
    </tr>
    <tr>
        <td>Enter Name:
        <td><input type=text name=name>
    </tr>
    <tr>
        <td>Enter City:
        <td><input name=city>
    </tr>
    <tr>
        <td colspan=2><input type=submit name="Insert" value="Insert">
        <input type=submit name="Delete" value="Delete">
        <input type=submit name="Update" value="Update">
        <input type=submit name="Display" value="Display">
    </tr>
</table>
<br><br>
<table border=1 style="cellpedding:6px">
<tr>
    <th>Roll
    <th>Name
    <th>City
//package to use sql classes
<%@page import="java.sql.*"%>
<%!
Connection con;
PreparedStatement ps;
//to establish the connection
public void connect()
{
    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        con=DriverManager.getConnection("jdbc:odbc:MyDb");
    }
    catch(Exception e){
        System.out.println(e);
    }
}
//single method to insert, update, delete
public void putData(String query)
{
    try{
    ps=con.prepareStatement(query);
    ps.executeUpdate();
    con.close();
    }
    catch(Exception e)
    {
        System.out.println(e);
    }
}
%>
<%
//calling the functions
if(request.getParameter("no")!=null && request.getParameter("name")!=null && request.getParameter("city")!=null)
{
    String roll=request.getParameter("no");
    String name=request.getParameter("name");
    String city=request.getParameter("city");
    connect();
    if(request.getParameter("Insert")!=null)
    {
        putData("insert into Stud values('"+roll+"','"+name+"','"+city+"')");
    }
    if(request.getParameter("Update")!=null)
    {
        putData("update Stud set name='"+name+"',city='"+city+"' where roll='"+roll+"'");
    }
    if(request.getParameter("Delete")!=null)
    {
        putData("delete from Stud where roll='"+roll+"'");
    }
}        ResultSet rs;
        try{
        ps=con.prepareStatement("select * from Stud");
        rs=ps.executeQuery();
        while(rs.next())
        {
        %>
          <tr>
            <td><%=rs.getString(1)%>
            <td><%=rs.getString(2)%>
            <td><%=rs.getString(3)%>
          </tr>
        <%}
        con.close();
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
%>
</tr>
</table>
</form>
</body>
</html>
Write data into file in binary format in java

Write data into file in binary format in java

import java.io.File;
import java.io.*;
import java.util.*;

class Student
{
//attributes
  int roll;
  String name;

  Student(int roll,String name)
  {
this.roll=roll;
this.name=name;
  }
  Student(String records)
  {
String fields[]=records.split("-");
this.roll=Integer.parseInt(fields[0]);
this.name=fields[1];
  }
  public String toString()
  {
 return Conversion.getBinary(String.valueOf(roll))+"-"+Conversion.getBinary(name);
  }
  static String objectToString(Student stud[])
  {
 StringBuffer bf=new StringBuffer();
 int i;
 for(i=0;i<stud.length-1;i++)
 {
 bf.append(stud[i]).append("#");
 }
 bf.append(stud[i]);
 return new String(bf);
  }
 
  static Student[] stringToObject(String str)
  {
 String s[]=str.split("#");
 Student[] stud=new Student[s.length];
 for(int i=0;i<stud.length;i++)
 {
 stud[i]=new Student(s[i]);
 }
 return stud;
  }
}


class Conversion
{
//decimal to binary
static String getBinary(String s)
{
char c[]=s.toCharArray(); //store all the characters of string
int asci;
StringBuffer sb=new StringBuffer();
String singlecode,sevenBit,withParity;

for(int i=0;i<c.length;i++)
{
asci=(int)c[i]; //find the ascii of value of char
singlecode=Integer.toBinaryString(asci); // convert into binary
sevenBit=Conversion.getSevenBit(singlecode); // add recommended zero's (gets seven bit digit)
withParity=Conversion.setParityBit(sevenBit); // set parity bit at the last index
sb.append(withParity).append(":"); //append all the binary codes in the var
}
sb=sb.deleteCharAt(sb.length()-1);
return new String(sb);
}
static String getSevenBit(String s)
{
StringBuffer sb=new StringBuffer();
for(int i=0;i<(7-s.length());i++)
{
sb.append("0"); // add zeros to the starting of string
}
sb.append(s);
return new String(sb);
}
static String setParityBit(String s)
{

int counter=0; // increse when found 1 in string
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)=='1') // 1 founded
{
counter++;
}
}
if(counter%2==0) // if counter has even
s=s.concat("0");
else
s=s.concat("1"); // if counter has odd
return s;
}

//binary to decimal
static String binaryToDecimal(String s)
{
int flag=0;
String bit="125:64:32:16:8:4:2:1";
String bitAr[]=bit.split(":");
StringBuffer binary=new StringBuffer();
for(int i=0;i<s.length()-1;i++)
{
if(s.charAt(i)==0)
flag=0;
else
binary.append(s.charAt(i));
}
for(int i=0;i<bitAr.length;i++)
{
System.out.println(bitAr[i]);
}
System.out.println();
return new String(binary);
}
}

class A
{
  public static void main(String ar[]) throws IOException
  {
Student[] stud=new Student[4];
stud[0]=new Student(1,"Mona");
stud[1]=new Student(2,"Mohit");
stud[2]=new Student(3,"Kapil");
stud[3]=new Student(4,"Vaishali");

System.out.println("Object To String : ");
String obTos=Student.objectToString(stud);
System.out.println(obTos);

// write into a file
FileWriter fw=new FileWriter(ar[0]);
fw.write(obTos);
fw.close();


//read from file
System.out.println();
BufferedReader br=new BufferedReader(new FileReader(ar[0]));
String rdstr=br.readLine();

System.out.println("String To Object : ");
Student sToOb[]=Student.stringToObject(rdstr);
for(int i=0;i<sToOb.length;i++)
{
System.out.println(sToOb.length);
}
//System.out.println(Conversion.binaryToDecimal("10000010"));
/*System.out.print("Enter String : ");
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
String str=bf.readLine();
String allBinaryCodes=Conversion.getBinary(str);
*/


  }
}

Kategori

Kategori