<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5768700980225572260</id><updated>2025-05-07T06:35:06.834-07:00</updated><category term="lesson1"/><category term="lesson2"/><category term="lesson3"/><category term="lesson4"/><category term="lesson5"/><category term="lesson6"/><category term="lesson7"/><category term="lesson8"/><title type='text'>javaZ</title><subtitle type='html'>codes for java console programs, jsp done in netbeans7.0.1</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-2858379425531740514</id><published>2012-04-08T10:42:00.001-07:00</published><updated>2012-04-12T23:58:42.762-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson5"/><title type='text'>Java code to write in a TEXT FILE</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This java program,creates a text file in the address specified if is not present and writes the content in this text file.If the text file is already present in the specified address, the content will be appended to the previously existing content.This program requires two class file,one is the java main class file(&lt;b&gt;WriteText.java&lt;/b&gt;) and other is the java class file(&lt;b&gt;WriteFile.java&lt;/b&gt;) which wites the content into the text file.Steps are given below.&lt;/div&gt;
&lt;b&gt;Steps&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Select&amp;nbsp;&lt;b&gt;Java&lt;/b&gt;&amp;nbsp;form the&amp;nbsp;&lt;i&gt;categories&amp;nbsp;&lt;/i&gt;and&amp;nbsp;&lt;b&gt;Java Application&amp;nbsp;&lt;/b&gt;&amp;nbsp;from the&amp;nbsp;&lt;i&gt;projects&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Next&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Set the&amp;nbsp;&lt;i&gt;Project name&amp;nbsp;&lt;/i&gt;as&amp;nbsp;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;writeText&amp;nbsp;&amp;nbsp;&lt;/b&gt;and set the&amp;nbsp;&lt;i&gt;Create Main Class&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Finish.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Under the&amp;nbsp;&amp;nbsp;project &quot;&lt;b&gt;writeText&quot;&lt;/b&gt;, you can see two files, double click the&amp;nbsp;&lt;b&gt;Source Packages&lt;/b&gt;,you can see a package by name&amp;nbsp;&lt;b&gt;&quot;&lt;/b&gt;&lt;b&gt;
&lt;b&gt;write&lt;/b&gt;text&amp;nbsp;&quot;&lt;/b&gt;&amp;nbsp;,double click it you will find the&amp;nbsp;&lt;i&gt;Java Main Class File&lt;/i&gt;,&amp;nbsp;&lt;b&gt;WriteText.java.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Right click the&amp;nbsp;&amp;nbsp; package&amp;nbsp; by name&amp;nbsp;&lt;b&gt;&quot;&lt;/b&gt;&lt;b&gt;
&lt;b&gt;&lt;b&gt;write&lt;/b&gt;text&lt;/b&gt;&amp;nbsp;&quot;&amp;nbsp;&lt;/b&gt;and select New -&amp;gt; Other&amp;nbsp;&lt;/li&gt;
&lt;li&gt;From&amp;nbsp;&lt;i&gt;Categories&amp;nbsp;&lt;/i&gt;select&amp;nbsp;&lt;b&gt;Java&amp;nbsp;&lt;/b&gt;and from&amp;nbsp;&lt;i&gt;File Types&amp;nbsp;&lt;/i&gt;select&amp;nbsp;&lt;b&gt;Java Class&lt;/b&gt;, click&amp;nbsp;&lt;i&gt;Next&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Set the&amp;nbsp;&lt;i&gt;Class Name&amp;nbsp;&lt;/i&gt;as &quot;&lt;b&gt;WriteFile.java&lt;/b&gt;&quot; and ensure the package name is&amp;nbsp;&amp;nbsp;&lt;b&gt;&quot;&lt;/b&gt;&lt;b&gt;
&lt;b&gt;&lt;b&gt;&lt;b&gt;write&lt;/b&gt;text&lt;/b&gt;&lt;/b&gt;&quot;.&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Now open the&amp;nbsp;
&lt;b style=&quot;text-align: justify;&quot;&gt;Write&lt;/b&gt;&lt;b&gt;Text.java&lt;/b&gt;,&amp;nbsp;remove the existing code and paste the following code :&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
------------------------------------------
&lt;b&gt;WriteText.java&lt;/b&gt;&lt;b&gt;----------------------------------------------------------&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
package writetext;&lt;br /&gt;
&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;* @author ZISSAN&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
public class WriteText {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public static void main(String[] args) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Enter the address of text file::&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Scanner in = new Scanner(System.in);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String address = in.nextLine();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //enter the address in this format &quot;C:/songs/newtest.txt&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;newtest.txt&quot; is the text file,if &quot;newtest.txt&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //is not present,this program will create this text&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //file in this address, &quot;C:/songs/&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WriteFile data = new WriteFile(address,true);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;WriteFile(address,true)&quot; has two arguments,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;address&quot; specifies the address of the text fule,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;true&quot; is aboolean value,specifies to append&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //the below content with the existing content&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Enter your text::&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String content=in.nextLine();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;content&quot; is a variable of string datatype,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //holds the content that to be stored in&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //assigned text file.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data.writeToFile(content);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (Exception er) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;error&quot;+er.getMessage()) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
-------------------------------------------------end of&amp;nbsp;&lt;b&gt;WriteText.java----------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Now open the&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&lt;b&gt;WriteFile.java&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;remove the existing code and paste the following code :&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;--------------------------------------------&lt;/span&gt;
&lt;b&gt;WriteFile.java&lt;/b&gt;&lt;b&gt;---------------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
package writetext;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.io.FileWriter;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;* @author ZISSAN&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
class WriteFile {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; private String path = &quot;&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; private boolean append_to_file = false;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //WriteFile() is the being called in&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //java main class file,Text.java&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public WriteFile(String file_name) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; path = file_name;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public WriteFile(String file_name, boolean append_value) //two constructor are used&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //first one is used when an user wants to overwrite the file&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //2nd one is used when an user wants to add xtra in the file&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; path=file_name;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; append_to_file=append_value;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public void writeToFile(String textLine) throws IOException{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; FileWriter write=new FileWriter(path,append_to_file);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; PrintWriter print_line=new PrintWriter(write);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print_line.printf(&quot;%s&quot;+&quot;%n&quot;,textLine);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print_line.close();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;-----------------------------------------&lt;/span&gt;&lt;b&gt;end&lt;/b&gt;&lt;b style=&quot;font-weight: bold;&quot;&gt;&amp;nbsp;of&amp;nbsp;WriteFile.java&lt;/b&gt;&lt;b style=&quot;font-weight: bold;&quot;&gt;----------------------------------------------------&lt;/b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/2858379425531740514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/04/java-code-to-write-in-text-file.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/2858379425531740514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/2858379425531740514'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/04/java-code-to-write-in-text-file.html' title='Java code to write in a TEXT FILE'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-3190815944190280743</id><published>2012-04-05T23:02:00.000-07:00</published><updated>2012-04-13T01:08:31.313-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson4"/><title type='text'>Java code to read the content of a TEXT FILE</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Steps&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Select&amp;nbsp;&lt;b&gt;Java&lt;/b&gt;&amp;nbsp;form the&amp;nbsp;&lt;i&gt;categories&amp;nbsp;&lt;/i&gt;and&amp;nbsp;&lt;b&gt;Java Application&amp;nbsp;&lt;/b&gt;&amp;nbsp;from the&amp;nbsp;&lt;i&gt;projects&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Next&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Set the&amp;nbsp;&lt;i&gt;Project name&amp;nbsp;&lt;/i&gt;as&amp;nbsp;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;readText&amp;nbsp;&amp;nbsp;&lt;/b&gt;and set the&amp;nbsp;&lt;i&gt;Create Main Class&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Finish.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Under the&amp;nbsp;&amp;nbsp;project &quot;&lt;b&gt;readText&quot;&lt;/b&gt;, you can see two files, double click the&amp;nbsp;&lt;b&gt;Source Packages&lt;/b&gt;,you can see a package by name&amp;nbsp;&lt;b&gt;&quot;&lt;/b&gt;&lt;b&gt;readtext&amp;nbsp;&quot;&lt;/b&gt;&amp;nbsp;,double click it you will find the&amp;nbsp;&lt;i&gt;Java Main Class File&lt;/i&gt;,&amp;nbsp;&lt;b&gt;ReadText.java.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Right click the&amp;nbsp;&amp;nbsp;
package&amp;nbsp;
by name&amp;nbsp;&lt;b&gt;&quot;&lt;/b&gt;&lt;b&gt;readtext&amp;nbsp;&quot; &lt;/b&gt;and select New -&amp;gt; Other&amp;nbsp;&lt;/li&gt;
&lt;li&gt;From &lt;i&gt;Categories &lt;/i&gt;select &lt;b&gt;Java &lt;/b&gt;and from &lt;i&gt;File Types &lt;/i&gt;select &lt;b&gt;Java Class&lt;/b&gt;, click &lt;i&gt;Next&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Set the &lt;i&gt;Class Name &lt;/i&gt;as &quot;&lt;b&gt;ReadFile.java&lt;/b&gt;&quot; and ensure the package name is&amp;nbsp;
&lt;b&gt;&quot;&lt;/b&gt;&lt;b&gt;readtext&amp;nbsp;&quot;.&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Now open the&amp;nbsp;&lt;b&gt;ReadText.java&lt;/b&gt;,&amp;nbsp;remove the existing and paste the following code :&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
------------------------------------------&lt;b&gt;ReadText.java------------------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
package readtext;&lt;/div&gt;
&lt;div&gt;
import java.util.Scanner;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
/**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* @author ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
public class ReadText {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param args the command line arguments&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public static void main(String[] args) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // TODO code application logic here&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int num=0;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;enter the text address::&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Scanner in=new Scanner(System.in);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String address=in.next();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //enter the address in this format &quot;C:/songs/test2.txt&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;test2.txt&quot; is the text file&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // &quot;C:/songs/&quot; is address in my pc&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReadFile file=new ReadFile(address);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//&quot;ReadFile&quot; is the name of the class,&quot;ReadFile()&quot; is the name of the constructor&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //constructor is also a method but its name is same as of the class&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //the address of the text file is given as argument of the constructor&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;file&quot; is the object&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String[] aryLines=file.OpenFile();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;OpenFile()&quot; is the method defined in the class ReadFile,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //encapsulated with &quot;file&quot;.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;aryLines&quot; is an array, stores the content&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // and gets the &quot;textData&quot; value from&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // &quot;OpenFile()&quot; method.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;file.readLines();i++)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&quot;readline()&quot; is a method defined to determine the lenght of&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //the content in the text file &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(aryLines[i]);//displays the content&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch(Exception er){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;exception has occured&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //displays the exception if&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //any io exception occurs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //to detect this exception,give&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //a name of unexisting filename&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //in the address above&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
-------------------------------------------------end of &amp;nbsp;&lt;b&gt;ReadText.java---------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Now open the&amp;nbsp;&lt;/span&gt;
&lt;b&gt;ReadFile.java&lt;/b&gt;&amp;nbsp;&lt;span style=&quot;font-weight: normal;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;remove the existing and paste the following code :&lt;/span&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;--------------------------------------------&lt;/span&gt;&lt;b&gt;ReadFile.java----------------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
package readtext;&lt;/div&gt;
&lt;div&gt;
import java.io.IOException;&lt;/div&gt;
&lt;div&gt;
import java.io.FileReader;&lt;/div&gt;
&lt;div&gt;
import java.io.BufferedReader;&lt;/div&gt;
&lt;div&gt;
/**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* @author ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
class ReadFile {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; private String path=&quot;&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;// variable &quot;path&quot; is declared globally&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; // so that its value can be used by all&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; // methods defined in the class &quot;ReadFile&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public ReadFile(String file_path){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; path=file_path;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //&quot;ReadFile()&quot; is the constructor,called in java&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; // main class file,&quot;Text.java&quot; and file_path&quot; gets&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; // the text file address&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public String[] OpenFile() throws IOException&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //&quot;OpenFile()&quot; opens the text file,reads the&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; // content and counts the number of line&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; int numberOfLines=readLines();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; String[] textData=new String[numberOfLines];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; int i;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; FileReader fr= new FileReader(path);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; BufferedReader textReader=new BufferedReader(fr);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;numberOfLines;i++)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; textData[i]=textReader.readLine();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; textReader.close();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //&quot;textReader&quot; is the buffer,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //is closed once the content&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //is stored in the array &quot;textData[]&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; return textData;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; int readLines() throws IOException&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //method readLines counts &quot;\n&quot; in the content&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //and therefore returns the number of line in the&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; //the text file&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; FileReader file_to_read=new FileReader(path);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; BufferedReader bf=new BufferedReader(file_to_read);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; String aLine;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; int numberOfLines=0;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; while((aLine=bf.readLine())!=null)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; numberOfLines++;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; bf.close();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; return(numberOfLines);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
-----------------------------------------------------end of&amp;nbsp;&lt;b&gt;ReadFile.java-------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
-------------------------------------------------------------output------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
run:&lt;/div&gt;
&lt;div&gt;
enter the text address::&lt;/div&gt;
&lt;div&gt;
C:/songs/test.txt&lt;/div&gt;
&lt;div&gt;
zissan chowdhury&lt;/div&gt;
&lt;div&gt;
zissan chowdhury&lt;/div&gt;
&lt;div&gt;
BUILD SUCCESSFUL (total time: 16 seconds)&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
----------------------------------------------&lt;b&gt;end of output---------------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/3190815944190280743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/04/java-code-to-read-content-of-text-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/3190815944190280743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/3190815944190280743'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/04/java-code-to-read-content-of-text-file.html' title='Java code to read the content of a TEXT FILE'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-1986268061965291285</id><published>2012-03-30T12:12:00.003-07:00</published><updated>2012-04-13T00:03:26.997-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson3"/><title type='text'>Implementation of POLYALPHABETIC SUBSTITUTION  CIPHER usin java(Encryption technique)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2&gt;











Steps&lt;/h2&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Select &lt;b&gt;Java&lt;/b&gt; form the&amp;nbsp;&lt;i&gt;categories&amp;nbsp;&lt;/i&gt;and&amp;nbsp;&lt;b&gt;Java Application&amp;nbsp;&lt;/b&gt;&amp;nbsp;from the&amp;nbsp;&lt;i&gt;projects&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Next.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Set the&amp;nbsp;&lt;i&gt;Project name&amp;nbsp;&lt;/i&gt;as&amp;nbsp;&lt;b&gt;&amp;nbsp;P&lt;/b&gt;&lt;span style=&quot;font-weight: 800;&quot;&gt;olyCiipher&lt;/span&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;and set the&amp;nbsp;&lt;i&gt;Create Main Class&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Finish.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Under the&amp;nbsp;&amp;nbsp;project &quot;&lt;b&gt;polyciipher&quot;&lt;/b&gt;, you can see two files, double click the&amp;nbsp;&lt;b&gt;Source Packages&lt;/b&gt;,you can see a package by name&amp;nbsp;&lt;b&gt;&quot;&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;font-weight: 800;&quot;&gt;polyciipher&lt;/span&gt;&lt;b&gt;&amp;nbsp;&quot;&lt;/b&gt;&amp;nbsp;,double click it you will find the&amp;nbsp;&lt;i&gt;Java Main Class File&lt;/i&gt;,&amp;nbsp;&lt;b&gt;PolyCiipher.java.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Open this file, remove the existing code and paste the following code.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
------------------------------------------&lt;b&gt;PolyCiipher.java.---------------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
package polyciipher;&lt;/div&gt;
&lt;div&gt;
import java.util.*;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
/**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* @author ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
public class PolyCiipher {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param args the command line arguments&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public static void main(String[] args) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int[] j = &amp;nbsp;new int[100];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int[] s = new int[100];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String test=&quot;&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // initialization of the Scanner class,handles input from user,can be found in the java.util.*; library.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // we are creating object &quot;in&quot; from the scanner and telling java that this will be System input&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Scanner in = new Scanner(System.in);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Enter the plain text(STRING SHOULD BE IN UPPERCASE AND DONT GIVE SPACE BETWEEN WORDS)::&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // next() is a method which &amp;nbsp;gets the next string of text that a user types on the keyboard&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; test = in.nextLine();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for ( int i = 0; i &amp;lt; test.length(); ++i ) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char c = test.charAt( i );// &quot;c&quot; holds the individual character of the string&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;s[i] = (int) c-65; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for(int i=0;i&amp;lt;test.length()-1;i++){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;j[i+1]=s[i];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Enter the key::&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int k = Integer.parseInt(in.nextLine());&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j[0]=k;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(); &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(&quot;The position of the character in the cipher text::&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int i=0;i&amp;lt;test.length();i++){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j[i]=j[i]+s[i];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j[i]=j[i]%26;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.print(j[i]);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;System.out.println(&quot;The cipher text::&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int i=0;i&amp;lt;test.length();i++){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char c=(char) (j[i]+65);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.print(c);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;System.out.println();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch(Exception er){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;--YOU HAVE TYPE INVALID DATA--&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
----------------------------------------------------------output---------------------------------------------------------------&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;
run:&lt;br /&gt;
Enter a string(STRING SHOULD BE IN ASCII AND DONT GIVE SPACE BETWEEN WORDS)::&lt;br /&gt;
&lt;b&gt;ATTACKISTONIGHT&lt;/b&gt;&lt;br /&gt;
Enter the key::&lt;br /&gt;
12&lt;br /&gt;
&lt;br /&gt;
1219121921218011712114130&lt;br /&gt;
&lt;b&gt;MTMTCMSALHBVONA&lt;/b&gt;&lt;br /&gt;
BUILD SUCCESSFUL (total time: 16 seconds)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/1986268061965291285/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/03/implementation-of-polyalphabetic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/1986268061965291285'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/1986268061965291285'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/03/implementation-of-polyalphabetic.html' title='Implementation of POLYALPHABETIC SUBSTITUTION  CIPHER usin java(Encryption technique)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-1369572372737769005</id><published>2012-03-30T08:47:00.000-07:00</published><updated>2012-04-13T00:03:50.953-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson2"/><title type='text'>Java code to convert the individual character of a string into its ascii value</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2&gt;






Steps&lt;/h2&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Select&amp;nbsp;&lt;b&gt;Java&lt;/b&gt;&amp;nbsp;form the&amp;nbsp;&lt;i&gt;categories&amp;nbsp;&lt;/i&gt;and&amp;nbsp;&lt;b&gt;Java Application&amp;nbsp;&lt;/b&gt;&amp;nbsp;from the&amp;nbsp;&lt;i&gt;projects&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Next.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Set the&amp;nbsp;&lt;i&gt;Project name&amp;nbsp;&lt;/i&gt;as&amp;nbsp;&lt;b&gt;
&lt;b&gt;ascii&lt;/b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;and set the&amp;nbsp;&lt;i&gt;Create Main Class&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Finish.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Under the&amp;nbsp;&amp;nbsp;project &quot;&lt;b&gt;ascii&quot;&lt;/b&gt;, you can see two files, double click the&amp;nbsp;&lt;b&gt;Source Packages&lt;/b&gt;,you can see a package by name&amp;nbsp;&lt;b&gt;&quot;
&lt;b&gt;ascii&lt;/b&gt;&amp;nbsp;&quot;&lt;/b&gt;&amp;nbsp;,double click it you will find the&amp;nbsp;&lt;i&gt;Java Main Class File&lt;/i&gt;,&amp;nbsp;&lt;b&gt;&amp;nbsp;A&lt;b&gt;scii&lt;/b&gt;&amp;nbsp;.java.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Open this file,
remove the existing code and&amp;nbsp;&amp;nbsp;paste the following code.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
------------------------------------------------A&lt;b&gt;scii.java-----------------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
package ascii;&lt;/div&gt;
&lt;div&gt;
import java.util.*;&lt;/div&gt;
&lt;div&gt;
/**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* @author ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
public class Ascii {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param args the command line arguments&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public static void main(String[] args) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // test is the input string&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String test=&quot;&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // initialization of the Scanner class,handles input from user,can be found in the java.util.*; library.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // we are creating object &quot;in&quot; from the scanner and telling java that this will be System input&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Scanner in = new Scanner(System.in);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Enter a string to convert it to ascii::&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // next() is a method which &amp;nbsp;gets the next string of text that a user types on the keyboard&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; test = in.nextLine();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for ( int i = 0; i &amp;lt; test.length(); ++i ) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char c = test.charAt( i );// &quot;c&quot; holds the individual character of the string&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int j = (int) c; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the value of &quot;c&quot; is parsed to integer type to get the required output&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(j); &amp;nbsp; // &quot;j&quot; holds the ascii value of the individual character&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
-------------------------------------------------------output------------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
run:&lt;/div&gt;
&lt;div&gt;
Enter a string to convert it o binary::&lt;/div&gt;
&lt;div&gt;
abcd&lt;/div&gt;
&lt;div&gt;
97&lt;/div&gt;
&lt;div&gt;
98&lt;/div&gt;
&lt;div&gt;
99&lt;/div&gt;
&lt;div&gt;
100&lt;/div&gt;
&lt;div&gt;
BUILD SUCCESSFUL (total time: 9 seconds)&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/1369572372737769005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-code-to-convert-individual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/1369572372737769005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/1369572372737769005'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-code-to-convert-individual.html' title='Java code to convert the individual character of a string into its ascii value'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-6152606966335291880</id><published>2012-03-30T08:32:00.000-07:00</published><updated>2012-04-13T00:04:36.517-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson1"/><title type='text'>java code to reverse a string</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2&gt;






Steps&lt;/h2&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Select&amp;nbsp;&lt;b&gt;Java&lt;/b&gt;&amp;nbsp;form the&amp;nbsp;&lt;i&gt;categories&amp;nbsp;&lt;/i&gt;and&amp;nbsp;&lt;b&gt;Java Application&amp;nbsp;&lt;/b&gt;&amp;nbsp;from the&amp;nbsp;&lt;i&gt;projects&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Next.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Set the&amp;nbsp;&lt;i&gt;Project name&amp;nbsp;&lt;/i&gt;as&amp;nbsp;&lt;b&gt;reverseString&amp;nbsp;&lt;/b&gt;and set the&amp;nbsp;&lt;i&gt;Create Main Class&lt;/i&gt;, click&amp;nbsp;&lt;b&gt;Finish.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Under the&amp;nbsp;&amp;nbsp;project &quot;&lt;b&gt;reverseString&quot;&lt;/b&gt;, you can see two files, double click the&amp;nbsp;&lt;b&gt;Source Packages&lt;/b&gt;,you can see a package by name&amp;nbsp;&lt;b&gt;&quot;reversestring&quot;&lt;/b&gt;&amp;nbsp;,double click it you will find the&amp;nbsp;&lt;i&gt;Java Main Class File&lt;/i&gt;,&amp;nbsp;&lt;b&gt;ReverseString.java.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Open this file,
remove the existing code and&amp;nbsp;&amp;nbsp;paste the following code.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
----------------------------------------------&lt;b&gt;ReverseString.java-------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
package reversestring;&lt;/div&gt;
&lt;div&gt;
import java.util.*;&lt;/div&gt;
&lt;div&gt;
/**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* @author ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
public class ReverseString {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param args the command line arguments&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public static void main(String[] args) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp;step.1. &amp;nbsp;initialize the two string.original will hold the input and reverse(set with a null value)&lt;/div&gt;
&lt;div&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; will hold the output&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String original, reverse =&quot;&quot;;&lt;/div&gt;
&lt;div&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp;step.2. &amp;nbsp;initialization of the Scanner class,handles input from user,can be found in the java.util.*; library. &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Scanner in = new Scanner(System.in);&lt;/div&gt;
&lt;div&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp; step.3. we are creating object &quot;in&quot; from the scanner and telling java that this will be System input&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Enter a string to reverse::&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; original = in.nextLine();&lt;/div&gt;
&lt;div&gt;
// next() is a method which &amp;nbsp;gets the next string of text that a user types on the keyboard&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; int length = original.length();&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for ( int i = length - 1 ; i &amp;gt;= 0 ; i-- )&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;reverse = reverse + original.charAt(i);&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Reverse of entered string ::&quot;+reverse);// prints the required output&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
--------------------------------------------------------output-----------------------------------------------------------------&lt;/div&gt;
&lt;br /&gt;
run:&lt;br /&gt;
Enter a string to reverse::&lt;br /&gt;
reverse&lt;br /&gt;
Reverse of entered string :: esrever&lt;br /&gt;
BUILD SUCCESSFUL (total time: 9 seconds)&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/6152606966335291880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-code-to-reverse-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/6152606966335291880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/6152606966335291880'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-code-to-reverse-string.html' title='java code to reverse a string'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-7016115577529710667</id><published>2012-03-28T09:10:00.001-07:00</published><updated>2012-04-13T00:00:59.567-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson6"/><title type='text'>Java code to generate a PDF</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Steps&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;From &lt;i&gt;category&lt;/i&gt;&amp;nbsp;directory, select &lt;b&gt;&amp;nbsp;Java&lt;/b&gt;&amp;nbsp;and from &lt;i&gt;project&lt;/i&gt; directory, select &lt;b&gt;Java Application&lt;/b&gt;, click &lt;b&gt;Next.&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;Set the &lt;i&gt;project &lt;/i&gt;name as &lt;b&gt;PDFWriter &lt;/b&gt;and deselect the &lt;b&gt;Create Main Class &lt;/b&gt;option, so to name the class and package by your own choice, click &lt;b&gt;Finish&lt;/b&gt;.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;Now you can see two files,&lt;b&gt;Source Package &lt;/b&gt;and &lt;b&gt;Libraries &lt;/b&gt;under the project name&amp;nbsp;
&lt;b&gt;PDFWriter&lt;/b&gt;.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;For this you need to have one &lt;b&gt;Java Main Class &lt;/b&gt;and one jar file,&lt;b&gt;itextpdf-5.2.0.jar&lt;/b&gt;(Download it).&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;Right click the&amp;nbsp;
&lt;b&gt;Source Package, &lt;/b&gt;select New-&amp;gt;Other-&amp;gt;Java-&amp;gt;Java Main Class.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;Set the name of the Java Main Class File as &lt;b&gt;FirstPDF &lt;/b&gt;and set the package name as &lt;b&gt;pdfJava&lt;/b&gt;, click &lt;b&gt;Finish&lt;/b&gt;.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;Right click the &lt;b&gt;Libraries&lt;/b&gt;,select &lt;b&gt;Add Jar/Folder &lt;/b&gt;and then&amp;nbsp;&amp;nbsp;add&amp;nbsp;&lt;b&gt;itextpdf-5.2.0.jar &lt;/b&gt;&amp;nbsp;the downloaded location.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;Now double click the&amp;nbsp;
&lt;b&gt;FirstPDF.java,&lt;/b&gt;&amp;nbsp;&lt;span style=&quot;text-align: left;&quot;&gt;remove the existing code and&lt;/span&gt;&amp;nbsp;&amp;nbsp;paste the following code.&lt;/li&gt;
&lt;/ol&gt;
---------------------------------------------
&lt;b style=&quot;text-align: justify;&quot;&gt;FirstPDF.java--------------------------------------------------------&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;* To change this template, choose Tools | Templates&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;* and open the template in the editor.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;package pdfJava;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
/**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* @author ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
import java.io.FileOutputStream;&lt;/div&gt;
&lt;div&gt;
import java.io.IOException;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
//import com.lowagie.text.Document;&lt;/div&gt;
&lt;div&gt;
//import com.lowagie.text.DocumentException;&lt;/div&gt;
&lt;div&gt;
//import com.lowagie.text.Paragraph;&lt;/div&gt;
&lt;div&gt;
//import com.lowagie.text.pdf.PdfWriter;&lt;/div&gt;
&lt;div&gt;
import com.itextpdf.text.Document;&lt;/div&gt;
&lt;div&gt;
import com.itextpdf.text.DocumentException;&lt;/div&gt;
&lt;div&gt;
import com.itextpdf.text.Paragraph;&lt;/div&gt;
&lt;div&gt;
import com.itextpdf.text.pdf.PdfWriter;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
public class&amp;nbsp;
&amp;nbsp;FirstPDF{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;/**&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Generates a PDF file with the text &#39;Hello World&#39;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Hello World&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// Step1: &amp;nbsp;A document-object is created&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Document document = new Document();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Step2:A writer is created that listens to the document and directs a &amp;nbsp;PDF-stream to a file.&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PdfWriter.getInstance(document, new FileOutputStream(&quot;C:/PDF/FirstPdf.pdf&quot;));&lt;/div&gt;
&lt;div&gt;
//&quot;C:/PDF/FirstPdf.pdf&quot; is the location at which pdf by name&amp;nbsp;FirstPdf.pdf will be created,PDF is the folder //name in &quot;C&quot; drive.&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Step3: Open the document&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;document.open();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Step4: Add a paragraph to the document&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;document.add(new Paragraph(&quot;Hello world&quot;));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (DocumentException dex) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.err.println(dex.getMessage());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (IOException ioex) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.err.println(ioex.getMessage());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// Step 5: Close the document&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;document.close();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;PDF is created sussecefully &quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
----------------------------------------------&lt;span style=&quot;font-weight: normal; text-align: left;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;FirstPDF.java----------------------------------------------------------------&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;For using this code in jsp,you can contact me through mail.&lt;/b&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/7016115577529710667/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-code-to-generate-pdf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/7016115577529710667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/7016115577529710667'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-code-to-generate-pdf.html' title='Java code to generate a PDF'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-4140576037767485827</id><published>2012-03-24T11:58:00.001-07:00</published><updated>2012-04-13T00:01:30.944-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson7"/><title type='text'>Java mail program</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;


Steps&lt;/h2&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Select java web from the categories list and select web-application from the project list and set the project name as SendingEmail and set all other properties as defaults.&lt;/li&gt;
&lt;li&gt;For this you need to have two jar files,&amp;nbsp;mail.jar and&amp;nbsp;activation-1.1.1.jar. Download these files and right click the libraries in the Netbeans 7.0.1 and select ADD JAR/FOLDER. Select these two jar files.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;Once this done, you need two have 3 jsp pages, index.jsp, success.jsp and error .jsp and one &amp;nbsp;servlet file, EmailServlet.java, to handle the request posted by the user from index.jsp&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
index.jsp---------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In index.jsp, you need to have 5 text box for sender email address set by name=&quot;from&quot;, receiver email address&amp;nbsp;set by name=&quot;to&quot;, subject&amp;nbsp;set by name=&quot;subject&quot;, login&amp;nbsp;set by name=&quot;login&quot; and password set by name=&quot;password&quot; in the index.jsp.It also requires one textarea for message set by name=&quot;message&quot; in the index.jsp.These parameters are received by servlet file EmailServlet.java and process the required operation,i.e if no exceptions occurs then it will redirect to the success.jsp page else it will redirect to the error.jsp page.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;Remove the existing code and p&lt;/span&gt;aste following code in the index.jsp&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
-------------------------------------------------index.jsp-----------------------------------------------------&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div&gt;
&amp;lt;%--&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Document &amp;nbsp; : index&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Created on : 24 Jan, 2012, 3:52:40 PM&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Author &amp;nbsp; &amp;nbsp; : ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Email-id &amp;nbsp; :ziszrcks@gmail.com&lt;/div&gt;
&lt;div&gt;
--%&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;html&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;head&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;Sending email&amp;lt;/title&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/head&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;body&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;center&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;form action=&quot;EmailServlet&quot; method=&quot;post&quot;&amp;gt; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;table&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;From&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; name=&quot;from&quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;To&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; name=&quot;to&quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;Subject&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; name=&quot;subject&quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;Message&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;textarea cols=&quot;25&quot; rows=&quot;8&quot; name=&quot;message&quot;&amp;gt;&amp;lt;/textarea&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;Login&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; name=&quot;login&quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;Password&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;password&quot; name=&quot;password&quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/table&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;submit&quot; value=&quot;submit&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/form&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/center&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/body&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div&gt;
------------------------------------------end of index.jsp--------------------------------------------------&lt;/div&gt;
&lt;div&gt;
After index.jsp, to compute the request or to handle the request we need a servlet file.This is done by writing the code in EmailServlet.java.For this right click the SourcePackage and select New--&amp;gt;Servlet--&amp;gt;&lt;/div&gt;
&lt;div&gt;
then set the class name as &quot;&lt;b&gt;EmailServlet.java&lt;/b&gt;&quot; and set the package name as &quot;&lt;b&gt;email&lt;/b&gt;&quot;.Once this has been done you can see under SourcePackage, package name &quot;&lt;b&gt;email&lt;/b&gt;&quot;.Then you need to set this servlet and its url pattern in web.xml. For this right click the SendingEmail project node and select New--&amp;gt;Other--&amp;gt;Web--&amp;gt;&lt;/div&gt;
&lt;div&gt;
Standard Deployment Descriptor (web.xml).Once selected,set properties as default.This file you will find &amp;nbsp;under the WEB-INF.&lt;br /&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;Remove the existing code and p&lt;/span&gt;aste&amp;nbsp;the following the code in web.xml&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
web.xml----------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
-----------------------------------------------web.xml-----------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;web-app version=&quot;2.5&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;servlet&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;servlet-name&amp;gt;EmailServlet&amp;lt;/servlet-name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;servlet-class&amp;gt;email.EmailServlet&amp;lt;/servlet-class&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/servlet&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;servlet-mapping&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;servlet-name&amp;gt;EmailServlet&amp;lt;/servlet-name&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;url-pattern&amp;gt;/EmailServlet&amp;lt;/url-pattern&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/servlet-mapping&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;session-config&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;session-timeout&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/session-timeout&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/session-config&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;welcome-file-list&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;welcome-file&amp;gt;index.jsp&amp;lt;/welcome-file&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/welcome-file-list&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/web-app&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
-----------------------------------------end of web.xml----------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Once servlet name, class and its url is set, then&amp;nbsp;&amp;nbsp;r&lt;span style=&quot;text-align: left;&quot;&gt;emove the existing code and p&lt;/span&gt;aste&amp;nbsp;the following the code&amp;nbsp;&amp;nbsp;in EmailServlet.java&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
EmailServlet.java-------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
For this you need to have an account in gmail, therefore you need to set the following properties,i.e host name,port number,enabling authenticaton and enabling encryption.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
-----------------------------------------EmailServlet.java--------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
/*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* To change this template, choose Tools | Templates&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* and open the template in the editor.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
package email;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
import java.io.*;&lt;/div&gt;
&lt;div&gt;
import java.net.*;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
import java.util.Properties;&lt;/div&gt;
&lt;div&gt;
import javax.mail.AuthenticationFailedException;&lt;/div&gt;
&lt;div&gt;
import javax.mail.Authenticator;&lt;/div&gt;
&lt;div&gt;
import javax.mail.PasswordAuthentication;&lt;/div&gt;
&lt;div&gt;
import javax.mail.Message;&lt;/div&gt;
&lt;div&gt;
import javax.mail.MessagingException;&lt;/div&gt;
&lt;div&gt;
import javax.mail.Session;&lt;/div&gt;
&lt;div&gt;
import javax.mail.Transport;&lt;/div&gt;
&lt;div&gt;
import javax.mail.internet.AddressException;&lt;/div&gt;
&lt;div&gt;
import javax.mail.internet.InternetAddress;&lt;/div&gt;
&lt;div&gt;
import javax.mail.internet.MimeMessage;&lt;/div&gt;
&lt;div&gt;
import javax.servlet.*;&lt;/div&gt;
&lt;div&gt;
import javax.servlet.http.*;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
/**&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;* @author ZISSAN&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
public class EmailServlet extends HttpServlet {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Processes requests for both HTTP &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;POST&amp;lt;/code&amp;gt; methods.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param request servlet request&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param response servlet response&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @throws ServletException if a servlet-specific error occurs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @throws IOException if an I/O error occurs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; protected void processRequest(HttpServletRequest request, HttpServletResponse response)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throws ServletException, IOException {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
//response.setContentType(&quot;text/html;charset=UTF-8&quot;);&lt;/div&gt;
&lt;div&gt;
//PrintWriter out = response.getWriter();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final String err = &quot;/error.jsp&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final String succ = &quot;/success.jsp&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String from = request.getParameter(&quot;from&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String to = request.getParameter(&quot;to&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String subject = request.getParameter(&quot;subject&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String message = request.getParameter(&quot;message&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String login = request.getParameter(&quot;login&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String password = request.getParameter(&quot;password&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Properties props = new Properties();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; props.setProperty(&quot;mail.host&quot;, &quot;smtp.gmail.com&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; props.setProperty(&quot;mail.smtp.port&quot;, &quot;587&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; props.setProperty(&quot;mail.smtp.auth&quot;, &quot;true&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; props.setProperty(&quot;mail.smtp.starttls.enable&quot;, &quot;true&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Authenticator auth = new SMTPAuthenticator(login, password);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Session session = Session.getInstance(props, auth);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MimeMessage msg = new MimeMessage(session);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg.setText(message);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg.setSubject(subject);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg.setFrom(new InternetAddress(from));&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Transport.send(msg);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (AuthenticationFailedException ex) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; request.setAttribute(&quot;ErrorMessage&quot;, &quot;Authentication failed&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RequestDispatcher dispatcher = request.getRequestDispatcher(err);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dispatcher.forward(request, response);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (AddressException ex) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; request.setAttribute(&quot;ErrorMessage&quot;, &quot;Wrong email address&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RequestDispatcher dispatcher = request.getRequestDispatcher(err);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dispatcher.forward(request, response);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (MessagingException ex) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; request.setAttribute(&quot;ErrorMessage&quot;, ex.getMessage());&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RequestDispatcher dispatcher = request.getRequestDispatcher(err);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dispatcher.forward(request, response);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RequestDispatcher dispatcher = request.getRequestDispatcher(succ);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dispatcher.forward(request, response);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; private class SMTPAuthenticator extends Authenticator {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private PasswordAuthentication authentication;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public SMTPAuthenticator(String login, String password) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; authentication = new PasswordAuthentication(login, password);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; protected PasswordAuthentication getPasswordAuthentication() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return authentication;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; // &amp;lt;editor-fold defaultstate=&quot;collapsed&quot; desc=&quot;HttpServlet methods. Click on the + sign on the left to edit the code.&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Handles the HTTP &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; method.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param request servlet request&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param response servlet response&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @throws ServletException if a servlet-specific error occurs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @throws IOException if an I/O error occurs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; @Override&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; protected void doGet(HttpServletRequest request, HttpServletResponse response)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throws ServletException, IOException {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; processRequest(request, response);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Handles the HTTP &amp;lt;code&amp;gt;POST&amp;lt;/code&amp;gt; method.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param request servlet request&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param response servlet response&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @throws ServletException if a servlet-specific error occurs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @throws IOException if an I/O error occurs&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; @Override&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; protected void doPost(HttpServletRequest request, HttpServletResponse response)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throws ServletException, IOException {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; processRequest(request, response);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /**&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Returns a short description of the servlet.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return a String containing servlet description&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; @Override&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public String getServletInfo() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return &quot;Short description&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }// &amp;lt;/editor-fold&amp;gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
----------------------------------------end of EmailServlet.java-------------------------------------------&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;
success.jsp&amp;nbsp;-----------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;Remove the existing code and p&lt;/span&gt;aste&amp;nbsp;the following the code
&lt;/div&gt;
&lt;div&gt;
----------------------------------------------success.jsp--------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;%--&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Document &amp;nbsp; : success&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Created on : 24 Jan, 2012, 4:03:33 PM&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Author &amp;nbsp; &amp;nbsp; : ZISSAN&lt;/div&gt;
&lt;div&gt;
--%&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;html&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;head&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;Message&amp;lt;/title&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/head&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;body&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;center&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div class=&quot;msg&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;h2&amp;gt;Message&amp;lt;/h2&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;p&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Email sent&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/p&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/div&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;/center&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/body&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
---------------------------------------end of &amp;nbsp;success.jsp--------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
error.jsp&amp;nbsp;--------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;Remove the existing code and p&lt;/span&gt;aste&amp;nbsp;the following the code
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
-----------------------------------------------error.jsp----------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;%--&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Document &amp;nbsp; : error&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Created on : 24 Jan, 2012, 4:02:53 PM&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Author &amp;nbsp; &amp;nbsp; : ZISSAN&lt;/div&gt;
&lt;div&gt;
--%&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;html&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;head&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;Error&amp;lt;/title&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/head&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;body&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;center&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div class=&quot;error&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;h2&amp;gt;Error&amp;lt;/h2&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;p&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Message: &amp;lt;%= request.getAttribute(&quot;ErrorMessage&quot;) %&amp;gt; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/p&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/div&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/center&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/body&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
-------------------------------------end of error.jsp-------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/4140576037767485827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-mail-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/4140576037767485827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/4140576037767485827'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/03/java-mail-program.html' title='Java mail program'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5768700980225572260.post-8121033642568041538</id><published>2012-03-18T00:38:00.000-07:00</published><updated>2012-04-13T00:02:05.783-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lesson8"/><title type='text'>Ajax autocomplete source code in jsp retrieving data from database</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;This project is done in netbeans7.0.1&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Steps for setting up the project&lt;br /&gt;
1.Select Java Web in categories directory in the left&lt;br /&gt;
2.Select Web Application in the project directory&lt;br /&gt;
3.Set the project name as &quot;autocomplete&quot;&lt;br /&gt;
4.Then click next&lt;br /&gt;
5.Set the JavaEE version: Java EE 6 Web and click finish&lt;br /&gt;
&lt;br /&gt;
For this two javascript files and two jsp pages (index.jsp and list.jsp) and one css( style.css )&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
1.jquery-1.4.2.min.js&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
2.jquery.autocomplete.js&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Place the above js file in a single folder by name &quot;JS&quot; under Web Pages(right click Web Pages and New &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt; &amp;nbsp;Other &amp;nbsp;-&amp;gt; &amp;nbsp;Other -&amp;gt; folder and name it JS) directory of the project by name &quot;autocomplete&quot; in netbeans&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
3.In the index.jsp, index.jsp will be present in Web Pages folder by default,dont delete it, remove the existing code and p&lt;span style=&quot;text-align: justify;&quot;&gt;aste&lt;/span&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;the following the code&lt;/span&gt;&amp;nbsp;:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
-----------------------------------------------index.jsp-----------------------------------------------------&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&lt;br /&gt;
&quot;http://www.w3.org/TR/html4/loose.dtd&quot;&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;!--author: zissan &amp;nbsp; &amp;nbsp; emailid:ziszrcks@gmail.com--&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/style.css&quot; /&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;JS/jquery-1.4.2.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;script src=&quot;JS/jquery.autocomplete.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;div style=&quot;width: 300px; margin: 50px auto;&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;b&amp;gt;Country&amp;lt;/b&amp;gt; &amp;nbsp; : &amp;lt;input type=&quot;text&quot; id=&quot;country&quot; name=&quot;country&quot; class=&quot;input_text&quot;/&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;jQuery(function(){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;$(&quot;#country&quot;).autocomplete(&quot;list.jsp&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
--------------------------------------end of index.jsp------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
4.In the list.jsp ,remove the existing code and p&lt;span style=&quot;text-align: justify;&quot;&gt;aste&lt;/span&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;the following the code&lt;/span&gt;:&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------list.jsp-----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--author: zissan &amp;nbsp;emailId: ziszrcks@gmail.com&lt;br /&gt;
.this page handles the request of id=country(in index.jsp)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;%@ page import=&quot;java.sql.*&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ page import=&quot;java.io.*&quot; %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; try{ &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Connection con;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Statement stmt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ResultSet rs;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; String host=&quot;jdbc:mysql://localhost:3306/books&quot;;&lt;br /&gt;
//books is the database name&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String uName=&quot;root&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String uPass=&quot;enter your password&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; con=DriverManager.getConnection(host,uName,uPass);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/* copy the countries name in the table &quot;country&quot; with a field name countries&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; countrieslist &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&quot;Afghanistan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Albania&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Algeria&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Andorra&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Angola&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Antigua and Barbuda&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Argentina&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Armenia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Australia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Austria&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Azerbaijan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Bahamas&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Bahrain&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Bangladesh&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Barbados&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Belarus&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Belgium&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Belize&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Benin&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Bhutan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Bolivia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Bosnia and Herzegovina&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Botswana&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Brazil&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Brunei&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Bulgaria&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Burkina Faso&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Burundi&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Cambodia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Cameroon&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Canada&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Cape Verde&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Central African Republic&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Chad&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Chile&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;China&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Colombi&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Comoros&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Congo (Brazzaville)&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Congo&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Costa Rica&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Cote d&#39;Ivoire&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Croatia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Cuba&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Cyprus&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Czech Republic&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Denmark&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Djibouti&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Dominica&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Dominican Republic&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;East Timor (Timor Timur)&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Ecuador&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Egypt&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;El Salvador&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Equatorial Guinea&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Eritrea&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Estonia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Ethiopia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Fiji&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Finland&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;France&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Gabon&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Gambia, The&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Georgia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Germany&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Ghana&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Greece&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Grenada&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Guatemala&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Guinea&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Guinea-Bissau&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Guyana&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Haiti&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Honduras&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Hungary&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Iceland&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;India&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Indonesia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Iran&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Iraq&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Ireland&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Israel&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Italy&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Jamaica&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Japan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Jordan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Kazakhstan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Kenya&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Kiribati&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Korea, North&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Korea, South&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Kuwait&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Kyrgyzstan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Laos&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Latvia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Lebanon&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Lesotho&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Liberia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Libya&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Liechtenstein&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Lithuania&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Luxembourg&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Macedonia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Madagascar&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Malawi&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Malaysia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Maldives&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Mali&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Malta&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Marshall Islands&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Mauritania&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Mauritius&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Mexico&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Micronesia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Moldova&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Monaco&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Mongolia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Morocco&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Mozambique&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Myanmar&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Namibia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Nauru&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Nepal&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Netherlands&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;New Zealand&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Nicaragua&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Niger&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Nigeria&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Norway&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Oman&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Pakistan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Palau&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Panama&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Papua New Guinea&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Paraguay&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Peru&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Philippines&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Poland&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Portugal&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Qatar&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Romania&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Russia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Rwanda&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Saint Kitts and Nevis&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Saint Lucia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Saint Vincent&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Samoa&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;San Marino&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Sao Tome and Principe&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Saudi Arabia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Senegal&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Serbia and Montenegro&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Seychelles&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Sierra Leone&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Singapore&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Slovakia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Slovenia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Solomon Islands&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Somalia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;South Africa&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Spain&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Sri Lanka&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Sudan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Suriname&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Swaziland&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Sweden&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Switzerland&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Syria&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Taiwan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Tajikistan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Tanzania&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Thailand&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Togo&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Tonga&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Trinidad and Tobago&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Tunisia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Turkey&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Turkmenistan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Tuvalu&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Uganda&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Ukraine&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;United Arab Emirates&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;United Kingdom&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;United States&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Uruguay&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Uzbekistan&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Vanuatu&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Vatican City&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Venezuela&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Vietnam&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Yemen&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Zambia&quot;,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;Zimbabwe&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;};*/&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String query = (String)request.getParameter(&quot;q&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String sql=&quot;select countries from country where countries like &#39;&quot;+query+&quot;%&#39;&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rs=stmt.executeQuery(sql);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rs.last();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int length=rs.getRow();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;response.setHeader(&quot;Content-Type&quot;, &quot;text/html&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int cnt=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(rs.first()){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int i=0;i&amp;lt;length;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(rs.getString(1).toUpperCase().startsWith(query.toUpperCase()))&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;out.print(rs.getString(1)+&quot;\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(cnt&amp;gt;=10)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;break;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;cnt++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rs.next();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;out.println(&quot;country name not in the database&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
%&amp;gt;&lt;br /&gt;
&amp;lt;%&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; catch(Exception e1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; out.println(&quot;cannot display the records&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------end of list.jsp---------------------------------------------------&lt;br /&gt;
place the two jsp in Web Pages foler directly&lt;br /&gt;
&lt;br /&gt;
5. For the style.css right click the Web Pages directory (New -&amp;gt; Other -&amp;gt; Other -&amp;gt; folder ) and name it &quot;css&quot;&lt;br /&gt;
and then right click the css folder (New -&amp;gt; Other -&amp;gt; Other -&amp;gt; CascadingStyleSheet ) and name it &quot;style.css&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; In the &quot;style.css&quot;, remove the existing code and p&lt;span style=&quot;text-align: justify;&quot;&gt;aste&lt;/span&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;the following the code&lt;/span&gt;:&lt;br /&gt;
----------------------------------------------style.css-------------------------------------------------------&lt;br /&gt;
&amp;nbsp;.ac_results {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;padding: 0px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;border: 1px solid #ff7c08;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;background-color: white;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;overflow: hidden;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.ac_results ul {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;width: 100%;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;list-style-position: outside;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;list-style: none;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;padding: 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;margin: 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.ac_results li {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;margin: 0px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;padding: 2px 5px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;cursor: default;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;display: block;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;color: #972800;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;font-family:Arial, Helvetica, sans-serif;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if width will be 100% horizontal scrollbar will apear&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;when scroll mode will be used&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*/&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*width: 100%;*/&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;font-size: 12px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;it is very important, if line-height not setted or setted&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;in relative units scroll will be broken in firefox&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*/&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;line-height: 16px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;overflow: hidden;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.ac_loading {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;background: white url(&#39;../images/indicator.gif&#39;) right center no-repeat;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.ac_odd {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;background-color: #fef2d8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.ac_over {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;background-color: #febb80;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;color: white;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.input_text{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;font-family:Arial, Helvetica, sans-serif;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;font-size:12px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;border:1px solid #FF7C08;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;padding:2px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;width:150px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;color:#802900;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;background:white url(../images/search.png) no-repeat 3px 2px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;padding-left:17px;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
-------------------------------------------end of style.css---------------------------------------------------&lt;/div&gt;
&lt;div&gt;
For this two images are required:&lt;/div&gt;
&lt;div&gt;
1. indicator.gif&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1sIxWe9FTUf6-6Qe6GqP713qaTjJCfE-OmuI3wPxJ-XxTvSKMZk1WTDnoGFe5lSwARs9NjqQuortrjxKgPysZLQgIXBXpZQ6G46tmwZGj2utWRNMDdiM8B1XrVTRY70GoMZzlrAN1BI/s1600/indicator.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1sIxWe9FTUf6-6Qe6GqP713qaTjJCfE-OmuI3wPxJ-XxTvSKMZk1WTDnoGFe5lSwARs9NjqQuortrjxKgPysZLQgIXBXpZQ6G46tmwZGj2utWRNMDdiM8B1XrVTRY70GoMZzlrAN1BI/s1600/indicator.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2.&amp;nbsp;search.png&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik-2F1KxUIFV0CJGdyuW3yqMMYk5GNeI01ZLo43XPt5MkyishxRcpJSiS78YmB18rKDknJfefOCyLVbGrfp0j_XEXD11JYT1lDKMKD1Dc9KAjulF0y2qHDR3tGvuKmOKxJ9RdapG5U4vw/s1600/search.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik-2F1KxUIFV0CJGdyuW3yqMMYk5GNeI01ZLo43XPt5MkyishxRcpJSiS78YmB18rKDknJfefOCyLVbGrfp0j_XEXD11JYT1lDKMKD1Dc9KAjulF0y2qHDR3tGvuKmOKxJ9RdapG5U4vw/s1600/search.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
--------------------------------------------screenshot-------------------------------------------------------&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW0UMvA8JAdpFkc8riBcs_z93wWDY8KvckSI7056ta9CptwHLmrWUHT9Mlms0BHUUX3xKz17Zrx2YEluGqiuAC5AUw7jwWfnQCp-1VwQYSQoFeIRREngntRHJ5AsIp8Kc7S0leW9WGAf8/s1600/autocomplete.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW0UMvA8JAdpFkc8riBcs_z93wWDY8KvckSI7056ta9CptwHLmrWUHT9Mlms0BHUUX3xKz17Zrx2YEluGqiuAC5AUw7jwWfnQCp-1VwQYSQoFeIRREngntRHJ5AsIp8Kc7S0leW9WGAf8/s640/autocomplete.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Srcreenshots&lt;br /&gt;
&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
------------------------------------------------sql command------------------------------------------------&lt;br /&gt;
databsename : books&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;/li&gt;
&lt;li&gt;CREATE TABLE country (countries VARCHAR(20) NOT NULL, PRIMARY KEY (countries));&lt;/li&gt;
&lt;li&gt;&lt;/li&gt;
&lt;li&gt;INSERT INTO books.country (countries) VALUES (&#39;Angola&#39;);&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javazworldz.blogspot.com/feeds/8121033642568041538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javazworldz.blogspot.com/2012/03/ajax-autocomplete-source-code-in-jsp.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/8121033642568041538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5768700980225572260/posts/default/8121033642568041538'/><link rel='alternate' type='text/html' href='http://javazworldz.blogspot.com/2012/03/ajax-autocomplete-source-code-in-jsp.html' title='Ajax autocomplete source code in jsp retrieving data from database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12598030216162752614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1sIxWe9FTUf6-6Qe6GqP713qaTjJCfE-OmuI3wPxJ-XxTvSKMZk1WTDnoGFe5lSwARs9NjqQuortrjxKgPysZLQgIXBXpZQ6G46tmwZGj2utWRNMDdiM8B1XrVTRY70GoMZzlrAN1BI/s72-c/indicator.gif" height="72" width="72"/><thr:total>4</thr:total></entry></feed>