Posts

Showing posts from December, 2017

Write a simple JSP program to display "M. Ed ICT" 10 times.

<html> <head> <title>A simple JSP program</title> </head> <body> <h1>Displaying "M. Ed ICT" 10 times! </h1> <table> <% for(int i=1; i<=10; i++) {             Out.println(“M.Ed ICT”); } %> </table> </body> </html>

what is servlet ? discuss different API's used in servlet programming. demonostrate with example.

java servlet is the server-side program that runs on a web server and handles clients request and returns a dynamic response to each request. the dynamic response could be based on user's input and with data retrieved from a database or other applications or time-sensitive data (such as news and stock prices).            the javax.servlet and javax.servlet.http packages interfaces and classes for servlet API.  The javax.servlet package contains many interfaces and classes that are used by a servlet or web container. There are many interfaces in javax.servlet package. Some of them are: servlet, servlet request, servletResponse, servletConfig, servletContext etc. Besides this, there are many classes in javax.servlet package. Some of them are: GenericServlet, ServletInputStream ServeletOutputStream, ServletRequestWrapper etc. a) Servelet Interfaces: Example:- import java.io.*; import javax.servlet.*; public class servlet implements servlet { servletConfig config =null; public

future trends in computers

1) The no of transistors in a computers chip would be double every 18 months that would also double the speed of the computer. 2)  quantum computers are under development, they use components of chloroform molecules to compute at the molecular level scientist will use quantum machines which describes the subatomic particles as the basis for computing. These computers may be very faster than the present computers. 3) progress in artificial intelligence will make intelligence computers that can learn and adopt the new environment and help the humans in many ways. 4) Advancement in a virtual system will increase the productivity of computers and also help to achieve green technology. 5) AI languages, VRML(virtual reality modeling languages) will be effectively used. 6)Progress in network and communication system will provide congestion-free high-speed internet for transmitting audio, video and large files over the internet.  7)Optimal security strategies will be developed to secure

what distinguish java beans from java classes?

A JavaBeans is software component that is written in Java programming language. It is similar to Java class except for following differences: * A JavaBean must adhere to certain convention regarding property and event interface definition whereas java class need not be. * A builder tool must be able to analyze how Beans works through introspection process.This is not necessarily to be true in case of a java class. * Java Beans must implement a serializable interface which is not necessary for Java classes. * Every java Beans must have one public no.argument constructor which is not true for Java classes.              In conclusion, it can be said that a Bean is a Java class, but a Java class may not be a Bean. Thus Beans is a specific java class and has rules that have to be followed, called design patterns.  

example of java socket programming

example //clint program     import java.net.*;     import java.io.*;     import java.util.*; public class myclint {     public static void main(String args[])throws IOException     {         Socket cs= new Socket("localhost",1254);//open  connection         Scanner ins=new Scanner(cs.getInputStream());         PrintWriter outs=new PrintWriter(cs.getOutputStream(),true);//perform IO         outs.println("hello Server");         String s=ins.nextLine();         System.out.println("from server::"+s);//close stream and connection         ins.close();         outs.close();         cs.close();     } } //server program         import java.net.*;         import java.io.*;         import java.util.*; public class myserver {     public static void main(String args[])throws IOException         //Register server on port 1234     {         ServerSocket ss= new ServerSocket(1234);//wait and accept a connection         Socket cs=ss.accept();

steps for writting server program

STEPS 1)Create the object of serversocket class         ServerSocket server = new ServerSocket(2345); this statement creates socket for the server and the argument represents the port number to which the server listens. 2)Accept the connection from the clint         socket clint=Server.accept(); after creating the socket it enters into the infinite loop and waits for the clint connection by using accept method. 3) Get input and output stream of the socket         Scanner ins=new Scanner(server.getInputStream());         PrintWriter outs =new PrintWriter(server.getOutputStream(),true); the first statement gets inputstream of server's socket and opens scanner on it,similerly,the second statement gets output stream of server's socket and opens Printwriters on it. 4) Read/write data to the socket             rs=ins.nextLine();             outs.println(ss); the first statement reads a line from server's socket and puts it in variable 'rs' and the second statement writes

steps foro writting clint programming

steps for writting clint program 1) open a socket     socket clint=new socket(Server_address,port id); this statement creates a socket for clint computer.while creating socket we need to provide IP address or domain name of the computer where server program executes and the port number in which server listens to the client. 2) open an input stream and output stream to the socket         Scanner ins= new Scanner(clint.getInputStream());         printwriter outs= new PrintWriter(clint.getOutputStream(),true); the first statement gets inputs stream class of clints socket and open scanner on it.Simillarly the second statements gets output stream of clints soket and open printWriter on it. 3) read from and write to the socket stream         rs=ins.nextLine();         outs.println(s); the first statement reads a line from clint's socket and puts it in variable 'rs' and the second statement write the value of string variable 'ss' into clint's socket. 4) close the state

database connectivity example

import java.sql.*; public class ConnectDB {     static final String JDBC_DRIVER="com.mysql.jdbc.Driver";     static final String DB_URL="jdbc:mysql://localhost/emp"; public static void main(String args[]); {     Connection conn= null;     Statement stmt=null; try {     //step2:Register JDBC driver     class.forName("com.mysql.jdbc.Driver");     //STEP:3 open a connection     System.out.println("Connection to database..........");     conn= DriverManager.getConnection(DB_URL,"root""password");     //STEP:4 execute a query     System.out.println("creating statement............");     stmt=conn.creatStatement();     String sql;     sql="SELECT eid,age,Fname,Lname,FORM employees";     ResultSet rs=stmt.executeQuery(sql);         //STEP:5 extract data from result set     while(rs.next())     {         //Retrieve by column name         int id=rs.getInt("eid");         int age=rs.getInt("age");

लोकसेवा

१. रास्ट्रीय चिकित्सा अध्यादेश मन्त्रीपरिषदबाट पारित:२०७४ कार्तिक ६ रास्ट्रपति बाट प्रमाणीकरण ,२०७४ कार्तिक २४ २. बि,सं २०७४ को विज्ञान प्रविधि पुरस्कार : अतुल मिश्र र अनिता बिन्दुलाइ प्रदान गरियो । ३. मदन पुरस्कार २०७३: घनस्याम कंडेल , धृत रास्ट्र ४.म्यान बुकर पुरस्कार 2017 :जर्ज सान्डर्स ५. म्यान बुकर इन्टरन्यासनल 2017: डेभिड ग्रसम्यान ६. सिंहदरबार बदल्ने संघर्ष, पुस्तकका लेखक : लालबाबु पण्डित ७.फिफा वर्ष खेलाडी 2017 : क्रीस्चियानो रोनाल्डो, ५ पटक ८. कम्युनिस्ट संग्रहालय कहाँ पर्दछ?:रुपन्देही , बुटवल ९.पद्मश्री पुरस्कार २०७३ :नवराज पराजुली १०.इम्जा हिमताल :सोलुखुम्बुमा पर्दछ । ११. नेपालमा कलेजो प्रत्यारोपण सुरु :२०७३ मंसिर २२ १२. मौद्रिक निति २०७४/७५ सार्वजनिक :२०७४ असार २५ १३. चिनियाँ साहित्यकार लिउ जिआवोको निधन : 2017 जुलाई 13 १४. इरानी रास्ट्रपतिमा हसन रुवानी विजयी :2017 मे 19 १५. नेपालमा थपिएको पछिल्लो विश्वविद्यालय : राजर्षी जनक विश्वविद्यालय १६. रास्ट्रपति सर्वोत्कृष्ट कृषक पुरस्कार २०७४: अफजल हुसेन , १ लाख पुरस्कार ,सर्लाही १७. द, कोरियामा नयाँ
Image
EXAMPLE 6 Construct deterministic finite-state automata that recognize each of these languages. (a) the set of bit strings that begin with two 0s (b) the set of bit strings that contain two consecutive 0s (c) the set of bit strings that do not contain two consecutive 0s (d) the set of bit strings that end with two 0s (e) the set of bit strings that contain at least two 0s Solution: (a) Our goal is to construct a deterministic finite-state automaton that recognizes the set of bit strings that begin with two 0s. Besides the start state s0, we include a nonfinal state s1; we move to s1 from s0 if the first bit is a 0. Next, we add a final state s2, which we move to from s1 if the second bit is a 0. When we have reached s2 we know that the first two input bits are both 0s, so we stay in the state s2 no matter what the succeeding bits (if any) are. We move to a nonfinal state s3 from s0 if the first bit is a 1 and from s1 if the second bit is a 1. The reader should verify that