<?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/opensearch/1.1/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;CUEAR3w-eip7ImA9WhZXFU8.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719</id><updated>2011-05-04T21:10:46.252+05:30</updated><title>Projects Free With Source Code</title><subtitle type='html'>projects with source code.In this site all department pdf files are available and projects are also can be download in this site.magazines are available.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>94</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;CkMCQHw8cCp7ImA9WhZXFU8.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-1119914632768604183</id><published>2011-05-04T20:17:00.000+05:30</published><updated>2011-05-04T20:17:41.278+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-04T20:17:41.278+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Popup Button'/><title>Popup Button</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
A PopupButton Component written by&lt;br /&gt;
Pat Paternostro&lt;br /&gt;
JDJ 5-10 p82&lt;br /&gt;
&lt;br /&gt;
Listing 1&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
&lt;br /&gt;
public abstract class PopupButton extends Button implements ActionListener&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;private PopupMenu popup;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;protected PopupButton(String[] items, Container parent)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; this("",items,parent);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;protected PopupButton(String label, String[] items, Container parent)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; super(label + " Û ");&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; popup = new PopupMenu();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; MenuItem menuItems[] = new MenuItem[items.length];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; for(int i = 0; i &amp;lt; items.length; i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;menuItems[i] = new MenuItem(items[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;menuItems[i].addActionListener(this);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;popup.add(menuItems[i]);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; parent.add(popup);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; addActionListener(new ActionListener() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;public void actionPerformed(ActionEvent evt) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; popup.show(PopupButton.this,0,PopupButton.this.getSize().height);}});&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Listing 2&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
&lt;br /&gt;
public class PopupButtonTest {&lt;br /&gt;
&amp;nbsp;public static void main(String args[]) {&lt;br /&gt;
&amp;nbsp; new PopupButtonTestFrame();&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class PopupButtonTestFrame extends Frame {&lt;br /&gt;
&amp;nbsp;Panel panel = new Panel();&lt;br /&gt;
&amp;nbsp;MyPopupButton mpb1 = new MyPopupButton("Colors",new String[]{"Red","Green","Blue"},this);&lt;br /&gt;
&amp;nbsp;MyPopupButton mpb2 = new MyPopupButton("Fruit",new String[]{"Apples","-","Oranges","-","Bannanas"},this);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;PopupButtonTestFrame() {&lt;br /&gt;
&amp;nbsp; super();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; /* Add the window listener */&lt;br /&gt;
&amp;nbsp; addWindowListener(new WindowAdapter() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;public void windowClosing(WindowEvent evt) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; dispose(); System.exit(0);}});&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; /* Size the frame */&lt;br /&gt;
&amp;nbsp; setSize(200,200);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; /* Center the frame */&lt;br /&gt;
&amp;nbsp; Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();&lt;br /&gt;
&amp;nbsp; Rectangle frameDim = getBounds();&lt;br /&gt;
&amp;nbsp; setLocation((screenDim.width - frameDim.width) / 2,(screenDim.height - frameDim.height) / 2);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; panel.add(mpb1);&lt;br /&gt;
&amp;nbsp; panel.add(mpb2);&lt;br /&gt;
&amp;nbsp; add(BorderLayout.NORTH,panel);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; /* Show the frame */&lt;br /&gt;
&amp;nbsp; setVisible(true);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class MyPopupButton extends PopupButton&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;public MyPopupButton(String label, String[] items, Container parent)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; super(label,items,parent);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;public void actionPerformed(ActionEvent evt)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; String command = evt.getActionCommand(); &amp;nbsp;System.out.println("You selected the " + command + "&lt;br /&gt;
&amp;nbsp;popup menu item!");&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-1119914632768604183?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/1119914632768604183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/05/popup-button.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1119914632768604183?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1119914632768604183?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/05/popup-button.html' title='Popup Button'/><author><name>saravanakumar</name><uri>http://www.blogger.com/profile/01443556085210469606</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='11468958506365280098'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CkUHR34-cCp7ImA9WhZXEk8.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-7771166095850890920</id><published>2011-04-30T22:57:00.001+05:30</published><updated>2011-05-01T08:53:56.058+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-01T08:53:56.058+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Creating Thread-Safe Servlets'/><title>Creating Thread-Safe Servlets</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;A servlet container allows multiple requests for the same  servlet by creating a different thread to service each request. In many cases,  each thread deals with its own ServletRequest and ServletResponse objects that  are isolated from other threads. Problems start to arise, however, when your  servlet needs to access an external resource. To understand the problem  introduced by multithreaded servlets, consider the following "playing dog"  illustration.&lt;/div&gt;&lt;div class="docText"&gt;Imagine a servlet accessing an external resource as a dog who  enjoys moving tennis balls from one box to another. Each box can hold ten balls,  no matter how the balls are arranged. The boxes and the balls are an external  resource to the dog. To play, the dog needs two boxes and ten balls. Initially,  those ten balls are placed in the first box. The dog moves all balls from the  first box to the second, one ball at a time. The dog is smart enough to count to  ten. Therefore, it knows when it's finished.&lt;/div&gt;&lt;div class="docText"&gt;Now imagine a second thread of the same servlet as a second dog  that plays the same game. Because there are only two boxes and ten balls for  both dogs, the two dogs share the same "external resource." The game goes like  this:&lt;/div&gt;&lt;span style="font-weight: bold;"&gt; &lt;ol class="docList" type="1"&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt; &lt;div class="docList"&gt;The first dog starts first (the servlet receives a call from a  user). &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;"&gt; &lt;div class="docList"&gt;After the first dog moves three balls, the second dog starts to  play (the servlet is invoked by the second user). What will happen?  &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/span&gt; &lt;div class="docText"&gt;The two dogs sharing the same balls are illustrated in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 2.6&lt;/a&gt;.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch02fig06"&gt;Figure 2.6. Understanding multi-threaded  code.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-n-AWwcyOMzE/TbxG4HW4QNI/AAAAAAAAAAw/denWhS7-v9s/s1600/a.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="204" src="http://3.bp.blogspot.com/-n-AWwcyOMzE/TbxG4HW4QNI/AAAAAAAAAAw/denWhS7-v9s/s320/a.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="docText"&gt;&lt;/div&gt;&lt;/center&gt; &lt;div class="docText"&gt;The first dog and the second dog will not find enough balls to  finish the game, and both will be confused.&lt;/div&gt;&lt;div class="docText"&gt;If somehow the second dog can be queued to wait to start until  the first dog finishes, however, the two dogs are happy.&lt;/div&gt;&lt;div class="docText"&gt;That's what happens when two threads of the same servlet need  to access an external resource, such as opening a file and writing to it.  Consider the following example, which reflects a real-world situation.&lt;/div&gt;&lt;div class="docText"&gt;The code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing  2.13&lt;/a&gt; presents a page counter servlet. What it does is simple. The servlet  overrides the service method to do the following:&lt;/div&gt;&lt;span style="font-weight: bold;"&gt; &lt;ol class="docList"&gt;&lt;li&gt;&lt;span style="font-weight: normal;" value="1"&gt; &lt;div class="docList"&gt;Open the counter.txt file using a BufferedReader, read the  number into a counter, and close the file. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="2"&gt; &lt;div class="docList"&gt;Increment the counter. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="3"&gt; &lt;div class="docList"&gt;Write the counter back to the counter.txt file. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="4"&gt; &lt;div class="docList"&gt;Display the counter in the web browser.  &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/span&gt; &lt;div class="docText"&gt;Imagine what happens if there are two users, Boni and Bulbul,  who request the servlet. First Boni requests it, and then a couple of  nanoseconds after Boni, Bulbul requests the same servlet. The scenario probably  looks like this:&lt;/div&gt;&lt;span style="font-weight: bold;"&gt; &lt;ol class="docList" type="1"&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt; &lt;div class="docList"&gt;The service method executes Steps 1 and 2, and then gets  distracted by the other request. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;"&gt; &lt;div class="docList"&gt;The method then does Step 1 from Bulbul before continuing to do  Step 3 and 4 for Boni. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/span&gt; &lt;div class="docText"&gt;What happens next? Boni and Bulbul get the same number, which  is not how it is supposed to be. The servlet has produced an incorrect result.  As you can see in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.13&lt;/a&gt;, the  servlet is an unsafe multithreaded servlet.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list13"&gt;Listing 2.13 Unsafe Multi-Threaded  Servlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.*; 

public class SingleThreadedServlet extends GenericServlet 
  {

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {
    int counter = 0; 

    // get saved value 
    try {
      BufferedReader reader = new BufferedReader(
        new FileReader("counter.txt")); 
        counter = Integer.parseInt( reader.readLine() ); 
        reader.close(); 
      } 
      catch (Exception e) {
      } 

      // increment counter 
      counter++; 

      // save new value 
      try {
        BufferedWriter writer = new BufferedWriter(
          new FileWriter("counter.txt")); 
        writer.write(Integer.toString(counter)); 

        writer.close(); 
      } 
      catch (Exception e) {
      } 

      try {
        PrintWriter out = response.getWriter(); 
        out.println("You are visitor number " + counter); 
      } 
      catch (Exception e) {
      } 
   } 
}&lt;/pre&gt;&lt;div class="docText"&gt;To solve the problem, remember the solution to the "playing  dog" illustration: When the second dog waited until the first dog finished  playing, both dogs could complete the game successfully.&lt;/div&gt;&lt;div class="docText"&gt;This is exactly how you solve the problem in a servlet needing  to service two users at the same time: by making the second user wait until the  first servlet finishes serving the first user. This solution makes the servlet  single-threaded.&lt;/div&gt;&lt;div class="docText"&gt;This solution is very easy to do because of the marker  SingleThreadedServlet interface. You don't need to change your code; you need  only to implement the interface.&lt;/div&gt;&lt;div class="docText"&gt;The code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing  2.14&lt;/a&gt; is the modification of the code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.13&lt;/a&gt;. Nothing changes, except that the  SingleThreadedServlet class now implements SingleThreadModel, making it thread  safe.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list14"&gt;Listing 2.14 Safe Multi-Threaded  Servlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.*; 

public class SingleThreadedServlet extends GenericServlet 
  implaments SingleThreadModel {

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {
    int counter = 0; 

    // get saved value 
    try {
      BufferedReader reader = new BufferedReader(
        new FileReader("counter.txt")); 
      counter = Integer.parseInt( reader.readLine() ); 
      reader.close(); 
    } 
    catch (Exception e) {
    } 

    // increment counter 
    counter++; 

    // save new value 
    try {
      BufferedWriter writer = new BufferedWriter(
        new FileWriter("counter.txt")); 
      writer.write(Integer.toString(counter)); 

      writer.close(); 
    } 
    catch (Exception e) {
    } 

    try {
      PrintWriter out = response.getWriter(); 
      out.println("You are visitor number " + counter); 
    } 
    catch (Exception e) {
    } 
  } 
}&lt;/pre&gt;&lt;div class="docText"&gt;Now, if a user requests the service of the servlet while the  servlet is servicing another user, the user who comes later will have to  wait.&lt;/div&gt;&lt;div class="docText"&gt;If you want to experience erroneous multi-threading yourself,  the code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.15&lt;/a&gt; provides the  SingleThreadedServlet with a delay of 6 seconds. Open two browsers and request  the same servlet quickly. Notice that you get the same number for both  browsers.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list15"&gt;Listing 2.15 Demonstrating an Unsafe  Multi-Threaded Servlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.*; 

public class SingleThreadedServlet extends GenericServlet {

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {
    int counter = 0; 

    // get saved value 
    try {
      BufferedReader reader = new BufferedReader(
        new FileReader("counter.txt")); 
      counter = Integer.parseInt( reader.readLine() ); 
      reader.close(); 
    } 
    catch (Exception e) {
    } 

    // increment counter 
    counter++; 

    // delay for 6 seconds to make observation possible 
    try {
      Thread thread = new Thread(); 
      thread.sleep(6000); 
    } 
    catch (InterruptedException e) {
    } 

    // saved new value 
    try {
      BufferedWriter writer = new BufferedWriter(
        new FileWriter("counter.txt")); 
      writer.write(Integer.toString(counter)); 

      writer.close(); 
    } 
    catch (Exception e) {
    } 

    try {
      PrintWriter out = response.getWriter(); 
      out.println("You are visitor number " + counter); 
    } 
    catch (Exception e) {
    } 
  } 
}&lt;/pre&gt;&lt;div class="docText"&gt;What the code does is simple: It opens the counter.txt file,  reads the value, increments the value, and writes the incremented value back to  the file.&lt;/div&gt;&lt;div class="docText"&gt;However, between the line of code that increments the value and  the line of code that writes the incremented value back to the user, we inserted  the following code:&lt;/div&gt;&lt;pre&gt;try {
  Thread thread = new Thread(); 
  thread.sleep(6000); 
} 
catch (InterruptedException e) {
}&lt;/pre&gt;&lt;div class="docText"&gt;Now you have time to request the same servlet from the second  browser. The value shown in both browsers will be the same if the second request  comes before the first thread of the servlet has the time to update the value in  the counter.txt file.&lt;/div&gt;&lt;div class="docText"&gt;An inexperienced programmer would wonder whether a good  solution might be to make every servlet implement the SingleThreadModel  interface. The answer is no. If a servlet never accesses an external resource,  queuing the second request will create unnecessary delay to the subsequent user  after the first. Also, if the external resource is accessed but there is no need  to update its value, you don't need to implement the SingleThreadModel  interface. For example, if the service method of a servlet needs only to read a  static value from a file, you can let multiple threads of the servlet open and  read the file at the same time.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-7771166095850890920?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/7771166095850890920/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/7771166095850890920?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/7771166095850890920?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-n-AWwcyOMzE/TbxG4HW4QNI/AAAAAAAAAAw/denWhS7-v9s/s72-c/a.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CkUHR34-cSp7ImA9WhZXEk8.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-2304059518467180114</id><published>2011-04-30T22:55:00.001+05:30</published><updated>2011-05-01T08:53:56.059+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-01T08:53:56.059+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='The GenericServlet Wrapper Class'/><title>The GenericServlet Wrapper Class</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;Throughout this chapter, you have been creating servlet classes  that implement the javax.servlet.Servlet interface. Everything works fine, but  there are two annoying things that you've probably noticed:&lt;/div&gt;&lt;span style="font-weight: bold;"&gt; &lt;ol class="docList" type="1"&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt; &lt;div class="docList"&gt;You have to provide implementations for all five methods of the  Servlet interface, even though most of the time you only need one. This makes  your code look unnecessarily complicated. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;"&gt; &lt;div class="docList"&gt;The ServletConfig object is passed to the init method. You need  to preserve this object to use it from other methods. This is not difficult, but  it means extra work. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/span&gt; &lt;div class="docText"&gt;The javax.servlet package provides a wrapper class called  GenericServlet that implements two important interfaces from the javax.servlet  package: Servlet and ServletConfig, as well as the java.io.Serializable  interface. The GenericServlet class provides implementations for all methods,  most of which are blank. You can extend GenericServlet and override only methods  that you need to use. Clearly, this looks like a better solution.&lt;/div&gt;&lt;div class="docText"&gt;The code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing  2.12&lt;/a&gt; is a servlet called SimpleServlet that extends GenericServlet. The code  provides the implementation of the service method that sends some output to the  browser. Because the service method is the only method you need, only this  method needs to appear in the class. Compared to all servlet classes that  implement the javax.servlet.Servlet interface directly, SimpleServlet looks much  cleaner and clearer.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list12"&gt;Listing 2.12 Extending  GenericServlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.IOException; 
import java.io.PrintWriter; 

public class SimpleServlet extends GenericServlet {

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {

    PrintWriter out = response.getWriter(); 
    out.println("&amp;lt;HTML&amp;gt;"); 
    out.println("&amp;lt;HEAD&amp;gt;"); 
    out.println("&amp;lt;TITLE&amp;gt;"); 
    out.println("Extending GenericServlet"); 
    out.println("&amp;lt;/TITLE&amp;gt;"); 
    out.println("&amp;lt;/HEAD&amp;gt;"); 
    out.println("&amp;lt;BODY&amp;gt;"); 
    out.println("Extending GenericServlet makes your code simpler."); 
    out.println("&amp;lt;/BODY&amp;gt;"); 
    out.println("&amp;lt;/HTML&amp;gt;"); 
  } 
}&lt;/pre&gt;&lt;div class="docText"&gt;The output from the SimpleServlet servlet is shown in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 2.5&lt;/a&gt;.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch02fig05"&gt;Figure 2.5. Extending GenericServlet.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-KYDvyZKI-d4/TbxGX8d5AkI/AAAAAAAAAAs/4KX9dHibpX0/s1600/a.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="204" src="http://1.bp.blogspot.com/-KYDvyZKI-d4/TbxGX8d5AkI/AAAAAAAAAAs/4KX9dHibpX0/s320/a.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="docText"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/center&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-2304059518467180114?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/2304059518467180114/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2304059518467180114?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2304059518467180114?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-KYDvyZKI-d4/TbxGX8d5AkI/AAAAAAAAAAs/4KX9dHibpX0/s72-c/a.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CE8HRX8ycSp7ImA9WhZXE0w.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-8269398152806526105</id><published>2011-04-30T22:52:00.001+05:30</published><updated>2011-05-02T10:37:14.199+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-02T10:37:14.199+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='The ServletResponse Interface'/><title>The ServletResponse Interface</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;The ServletResponse interface represents the response to the  user. The most important method of this interface is getWriter, from which you  can obtain a java.io.PrintWriter object that you can use to write HTML tags and  other text to the user.&lt;/div&gt;&lt;div class="docText"&gt;The code in Listings &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;2.10&lt;/a&gt; and &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;2.11&lt;/a&gt;  offer an HTML file named index2.html and a servlet whose service method is  overridden with code that outputs some HTML tags to the user. This servlet  modifies the example in Listings &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;2.8&lt;/a&gt; and  &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;2.9&lt;/a&gt; that retrieves various information  about the user. Instead of sending the information to the console, the service  method sends it back to the user.&lt;/div&gt;&lt;div class="docText"&gt;Note that the code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.10&lt;/a&gt; is similar to the code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.8&lt;/a&gt;, except that in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.10&lt;/a&gt; the value for the form's ACTION attribute is  servlet/ResponseDemoServlet.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list10"&gt;Listing 2.10 index2.html&lt;/h5&gt;&lt;pre&gt;&amp;lt;HTML&amp;gt; 
&amp;lt;HEAD&amp;gt; 
&amp;lt;TITLE&amp;gt;Sending a request&amp;lt;/TITLE&amp;gt; 
&amp;lt;/HEAD&amp;gt; 
&amp;lt;BODY&amp;gt; 
&amp;lt;FORM ACTION=servlet/ResponseDemoServlet METHOD="POST"&amp;gt; 
&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt; 
Author: &amp;lt;INPUT TYPE="TEXT" NAME="Author"&amp;gt; 
&amp;lt;INPUT TYPE="SUBMIT" NAME="Submit"&amp;gt; 
&amp;lt;INPUT TYPE="RESET" VALUE="Reset"&amp;gt; 
&amp;lt;/FORM&amp;gt; 
&amp;lt;/BODY&amp;gt; 
&amp;lt;/HTML&amp;gt;&lt;/pre&gt;&lt;h5 class="docExampleTitle" id="ch02list11"&gt;Listing 2.11 The  ResponseDemoServlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.PrintWriter; 
import java.io.IOException; 
import java.util.Enumeration; 

public class ResponseDemoServlet implements Servlet {

  public void init(ServletConfig config) throws ServletException {
  } 
  public void destroy() {
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {

    PrintWriter out = response.getWriter(); 
    out.println("&amp;lt;HTML&amp;gt;"); 
    out.println("&amp;lt;HEAD&amp;gt;"); 
    out.println("&amp;lt;TITLE&amp;gt;"); 
    out.println("ServletResponse"); 
    out.println("&amp;lt;/TITLE&amp;gt;"); 
    out.println("&amp;lt;/HEAD&amp;gt;"); 
    out.println("&amp;lt;BODY&amp;gt;"); 
    out.println("&amp;lt;B&amp;gt;Demonstrating the ServletResponse object&amp;lt;/B&amp;gt;"); 
    out.println("&amp;lt;BR&amp;gt;"); 

    out.println("&amp;lt;BR&amp;gt;Server Port: " + request.getServerPort()); 
    out.println("&amp;lt;BR&amp;gt;Server Name: " + request.getServerName()); 
    out.println("&amp;lt;BR&amp;gt;Protocol: " + request.getProtocol()); 
    out.println("&amp;lt;BR&amp;gt;Character Encoding: " + request.getCharacterEncoding()); 
    out.println("&amp;lt;BR&amp;gt;Content Type: " + request.getContentType()); 
    out.println("&amp;lt;BR&amp;gt;Content Length: " + request.getContentLength()); 
    out.println("&amp;lt;BR&amp;gt;Remote Address: " + request.getRemoteAddr()); 
    out.println("&amp;lt;BR&amp;gt;Remote Host: " + request.getRemoteHost()); 
    out.println("&amp;lt;BR&amp;gt;Scheme: " + request.getScheme()); 
    Enumeration parameters = request.getParameterNames(); 
    while (parameters.hasMoreElements()) {
      String parameterName = (String) parameters.nextElement(); 
      out.println("&amp;lt;br&amp;gt;Parameter Name: " + parameterName); 
      out.println("&amp;lt;br&amp;gt;Parameter Value: " + 
        request.getParameter(parameterName)); 
    } 
    Enumeration attributes = request.getAttributeNames(); 
    while (attributes.hasMoreElements()) {
      String attribute = (String) attributes.nextElement(); 
      out.println("&amp;lt;BR&amp;gt;Attribute name: " + attribute); 
      out.println("&amp;lt;BR&amp;gt;Attribute value: " + request.getAttribute(attribute)); 
    } 
    out.println("&amp;lt;/BODY&amp;gt;"); 
    out.println("&amp;lt;/HTML&amp;gt;"); 
  } 

  public String getServletInfo() {
    return null; 
  } 

  public ServletConfig getServletConfig() {
    return null; 
  } 

}&lt;/pre&gt;&lt;div class="docText"&gt;To run the example, first request the index2.html file by using  the following URL:&lt;/div&gt;&lt;pre&gt;http://localhost:8080/myApp/index2.html&lt;/pre&gt;&lt;div class="docText"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 2.3&lt;/a&gt; shows the  index2.html file in which "haywood" has been typed in as the value for  author.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch02fig03"&gt;Figure 2.3. The index2.html file.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-xSgjJs2d030/TbxFx9X46PI/AAAAAAAAAAo/ebD5eZl8rgE/s1600/a.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="204" src="http://3.bp.blogspot.com/-xSgjJs2d030/TbxFx9X46PI/AAAAAAAAAAo/ebD5eZl8rgE/s320/a.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="docText"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/center&gt; &lt;div class="docText"&gt;When you submit the form, the ResponseDemoServlet is invoked  and your browser should display an image similar to &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 2.4&lt;/a&gt;.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch02fig04"&gt;Figure 2.4. Utilizing the ServletResponse  object.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-_1kuRc_CuMU/TbxFv_BIzUI/AAAAAAAAAAk/mR6xIKy-5es/s1600/aa.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="204" src="http://1.bp.blogspot.com/-_1kuRc_CuMU/TbxFv_BIzUI/AAAAAAAAAAk/mR6xIKy-5es/s320/aa.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="docText"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/center&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-8269398152806526105?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/8269398152806526105/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8269398152806526105?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8269398152806526105?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-xSgjJs2d030/TbxFx9X46PI/AAAAAAAAAAo/ebD5eZl8rgE/s72-c/a.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CE8HRXw7eCp7ImA9WhZXE0w.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-4999485164401458491</id><published>2011-04-30T22:48:00.001+05:30</published><updated>2011-05-02T10:37:14.200+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-02T10:37:14.200+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='The ServletRequest Interface'/><title>The ServletRequest Interface</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;Requests and responses are what a web application is all about.  In a servlet application, a user using a web browser sends a request to the  servlet container, and the servlet container passes the request to the  servlet.&lt;/div&gt;&lt;div class="docText"&gt;In a servlet paradigm, the user request is represented by the  ServletRequest object passed by the servlet container as the first argument to  the service method. The service method's second argument is a ServletResponse  object, which represents the response to the user.&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch02lev2sec5"&gt;The ServletRequest Interface&lt;/h4&gt;&lt;div class="docText"&gt;The ServletRequest interface defines an object used to  encapsulate information about the user's request, including parameter name/value  pairs, attributes, and an input stream.&lt;/div&gt;&lt;div class="docText"&gt;The ServletRequest interface provides important methods that  enable you to access information about the user. For example, the  getParameterNames method returns an Enumeration containing the parameter names  for the current request. To get the value of each parameter, the ServletRequest  interface provides the getParameter method.&lt;/div&gt;&lt;div class="docText"&gt;The getRemoteAddress and getRemoteHost methods are two methods  that you can use to retrieve the user's computer identity. The first returns a  string representing the IP address of the computer the client is using, and the  second method returns a string representing the qualified host name of the  computer.&lt;/div&gt;&lt;div class="docText"&gt;The following example, shown in Listings &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;2.8&lt;/a&gt; and &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;2.9&lt;/a&gt;,  shows a ServletRequest object in action. The example consists of an HTML form in  a file named index.html that you need to put in the application directory—that  is, under myApp—and a servlet called RequestDemoServlet.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list08"&gt;Listing 2.8 index.html&lt;/h5&gt;&lt;pre&gt;&amp;lt;HTML&amp;gt; 
&amp;lt;HEAD&amp;gt; 
&amp;lt;TITLE&amp;gt;Sending a request&amp;lt;/TITLE&amp;gt; 
&amp;lt;/HEAD&amp;gt; 
&amp;lt;BODY&amp;gt; 
&amp;lt;FORM ACTION=servlet/RequestDemoServlet METHOD="POST"&amp;gt; 
&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt; 
Author: &amp;lt;INPUT TYPE="TEXT" NAME="Author"&amp;gt; 
&amp;lt;INPUT TYPE="SUBMIT" NAME="Submit"&amp;gt; 
&amp;lt;INPUT TYPE="RESET" VALUE="Reset"&amp;gt; 
&amp;lt;/FORM&amp;gt; 
&amp;lt;/BODY&amp;gt; 
&amp;lt;/HTML&amp;gt;&lt;/pre&gt;&lt;h5 class="docExampleTitle" id="ch02list09"&gt;Listing 2.9 RequestDemoServlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.util.Enumeration; 
import java.io.IOException; 

public class RequestDemoServlet implements Servlet {

  public void init(ServletConfig config) throws ServletException {
  } 

  public void destroy() {
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {

    System.out.println("Server Port: " + request.getServerPort()); 
    System.out.println("Server Name: " + request.getServerName()); 
    System.out.println("Protocol: " + request.getProtocol()); 
    System.out.println("Character Encoding: " + 
      request.getCharacterEncoding()); 
    System.out.println("Content Type: " + request.getContentType()); 
    System.out.println("Content Length: " + request.getContentLength()); 
    System.out.println("Remote Address: " + request.getRemoteAddr()); 
    System.out.println("Remote Host: " + request.getRemoteHost()); 
    System.out.println("Scheme: " + request.getScheme()); 
    Enumeration parameters = request.getParameterNames(); 
    while (parameters.hasMoreElements()) {
      String parameterName = (String) parameters.nextElement(); 
      System.out.println("Parameter Name: " + parameterName); 
      System.out.println("Parameter Value: " + 
        request.getParameter(parameterName)); 
    } 
    Enumeration attributes = request.getAttributeNames(); 
    while (attributes.hasMoreElements()) {
      String attribute = (String) attributes.nextElement(); 
      System.out.println("Attribute name: " + attribute); 
      System.out.println("Attribute value: " + 
        request.getAttribute(attribute)); 
    } 
  } 

  public String getServletInfo() {
    return null; 
  } 

  public ServletConfig getServletConfig() {
    return null; 
  } 

}&lt;/pre&gt;&lt;div class="docText"&gt;To run the example, first request the index.html file by using  the following URL:&lt;/div&gt;&lt;pre&gt;http://localhost:8080/myApp/index.html&lt;/pre&gt;&lt;div class="docText"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 2.2&lt;/a&gt; shows the  index.html file in which "haywood" has been typed in as the value for  author.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch02fig02"&gt;Figure 2.2. The index.html file.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-iajB6u6yNcE/TbxE9q5aQoI/AAAAAAAAAAg/7Dsx5-4nUs4/s1600/a.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="204" src="http://3.bp.blogspot.com/-iajB6u6yNcE/TbxE9q5aQoI/AAAAAAAAAAg/7Dsx5-4nUs4/s320/a.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="docText"&gt;&lt;/div&gt;&lt;/center&gt; &lt;div class="docText"&gt;When you submit the form, you should see the list of attribute  names and values in your console.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-4999485164401458491?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/4999485164401458491/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/4999485164401458491?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/4999485164401458491?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-iajB6u6yNcE/TbxE9q5aQoI/AAAAAAAAAAg/7Dsx5-4nUs4/s72-c/a.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0cAR3Y7fyp7ImA9WhZXE0k.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-3972179783496239314</id><published>2011-04-30T22:47:00.001+05:30</published><updated>2011-05-02T19:34:06.807+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-02T19:34:06.807+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Sharing Information Among Servlets'/><title>Sharing Information Among Servlets</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;For some applications, you want to make certain types of  information available to all the servlets. You can share this information—such  as a database connection string or a page count—among the servlets by using  attributes in the ServletContext object.&lt;/div&gt;&lt;div class="docText"&gt;The following example uses two servlets: AttributeSetterServlet  and DisplayAttributesServlet. The AttributeSetterServlet servlet, shown in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.6&lt;/a&gt;, binds the name password to a  String object containing the word "ding-dong". The servlet does this by first  obtaining the ServletContext object from the ServletConfig object passed by the  servlet container to the init method. Then the servlet uses the setAttribute  method to bind "password" with "ding-dong".&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list06"&gt;Listing 2.6 The  AttributeSetterServlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.IOException; 

public class AttributeSetterServlet implements Servlet {

  public void init(ServletConfig config) throws ServletException {
    // bind an object that is to be shared among other servlets 
    ServletContext servletContext = config.getServletContext(); 
    servletContext.setAttribute("password", "dingdong"); 
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {
  } 

  public void destroy() {
  } 

  public String getServletInfo() {
    return null; 
  } 
  public ServletConfig getServletConfig() {
    return null; 
  } 
}&lt;/pre&gt;&lt;div class="docText"&gt;The code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.7&lt;/a&gt;  is the servlet that retrieves all attribute name/value pairs in the  ServletContext object. The init method of this servlet preserves the  ServletConfig object into servletConfig. The service method then uses the  ServletConfig interface's getServletContext method to obtain the ServletContext  object. After you get the ServletContext object, you can then use its  getAttributeNames method to get an Enumeration of all attribute names and loop  through it to obtain each attribute's value, which it outputs to the console  along with the attribute name.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list07"&gt;Listing 2.7  DisplayAttributesServlet&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.IOException; 
import java.util.Enumeration; 

public class ResponseDemoServlet implements Servlet {
  ServletConfig servletConfig; 

  public void init(ServletConfig config) throws ServletException {
    servletConfig = config; 
  } 

  public void destroy() {
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {

    ServletContext servletContext = servletConfig.getServletContext(); 
    Enumeration attributes = servletContext.getAttributeNames(); 
    while (attributes.hasMoreElements()) {
      String attribute = (String) attributes.nextElement(); 
      System.out.println("Attribute name : " + attribute); 
      System.out.println("Attribute value : " + 
        servletContext.getAttribute(attribute)); 
    } 
  } 

  public String getServletInfo() {
    return null; 
  } 
  public ServletConfig getServletConfig() {
    return null; 
  } 

}&lt;/pre&gt;&lt;pre&gt;Enumeration attributes = servletContext.getAttributeNames(); 
  while (attributes.hasMoreElements()) {
    String attribute = (String) attributes.nextElement(); 
    System.out.println("Attribute name : " + attribute); 
    System.out.println("Attribute value : " + 
      servletContext.getAttribute(attribute)); 
}&lt;/pre&gt;&lt;div class="docText"&gt;To see the servlets work, first you need to call the  AttributeSetterServlet servlet to set the attribute "password". You then call  the DisplayAttributesServlet to get an Enumeration of the names of all  attributes and display the values.&lt;/div&gt;&lt;div class="docText"&gt;The output is given here:&lt;/div&gt;&lt;pre&gt;Attribute name : javax.servlet.context.tempdir 
Attribute value : C:\123data\JavaProjects\JavaWebBook\work\localhost_8080 
Attribute name : password 
Attribute value : dingdong 
Attribute name : sun.servlet.workdir 
Attribute value : C:\123data\JavaProjects\JavaWebBook\work\localhost_8080&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-3972179783496239314?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/3972179783496239314/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/3972179783496239314?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/3972179783496239314?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0cAR3Y7fyp7ImA9WhZXE0k.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-2289294097006999377</id><published>2011-04-30T22:46:00.001+05:30</published><updated>2011-05-02T19:34:06.807+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-02T19:34:06.807+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='The Servlet Context'/><title>The Servlet Context</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;In servlet programming, the servlet context is the environment  where the servlet runs. The servlet container creates a ServletContext object  that you can use to access information about the servlet's environment.&lt;/div&gt;&lt;div class="docText"&gt;A servlet also can bind an object attribute into the context by  name. Any object bound into a context is available to any other servlet that is  part of the same web application.&lt;/div&gt;&lt;div class="docText"&gt;How do you obtain the ServletContext object? Indirectly, from  the ServletConfig object passed by the servlet container to the servlet's init  method. The ServletConfig interface has a method called getServletContext that  returns the ServletContext object. You then can use the ServletContext  interface's various methods to get the information you need. These methods  include the following:&lt;/div&gt;&lt;ul&gt;&lt;li&gt; &lt;div class="docText"&gt;&lt;span class="docEmphStrong"&gt;getMajorVersion.&lt;/span&gt; This method  returns an integer representing the major version for the servlet API that the  servlet container supports. If the servlet container supports the servlet API  version 2.3, this method will return 2. &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docText"&gt;&lt;span class="docEmphStrong"&gt;getMinorVersion.&lt;/span&gt; This method  returns an integer representing the minor version of the servlet API that the  servlet container supports. For the servlet API version 2.3, this method will  return 3. &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docText"&gt;&lt;span class="docEmphStrong"&gt;getAttributeNames.&lt;/span&gt; This method  returns an enumeration of strings representing the names of the attributes  currently stored in the ServletContext. &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docText"&gt;&lt;span class="docEmphStrong"&gt;getAttribute.&lt;/span&gt; This method  accepts a String containing the attribute name and returns the object bound to  that name. &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docText"&gt;&lt;span class="docEmphStrong"&gt;setAttribute.&lt;/span&gt; This method  stores an object in the ServletContext and binds the object to the given name.  If the name already exists in the ServletContext, the old bound object will be  replaced by the object passed to this method. &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docText"&gt;&lt;span class="docEmphStrong"&gt;removeAttribute.&lt;/span&gt; This method  removes from the ServletContext the object bound to a name. The removeAttribute  method accepts one argument: the name of the attribute to be removed.  &lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="docText"&gt;The code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.5&lt;/a&gt;  shows a servlet named ContextDemoServlet that retrieves some of the servlet  context information, including attribute names and values, minor and major  versions of the servlet container, and the server info.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list05"&gt;Listing 2.5 Retrieving Servlet Context  Information&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.util.Enumeration; 
import java.io.IOException; 

public class ContextDemoServlet implements Servlet {
  ServletConfig servletConfig; 

  public void init(ServletConfig config) throws ServletException {
    servletConfig = config; 
  } 

  public void destroy() {
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {  
    ServletContext servletContext = servletConfig.getServletContext(); 
    Enumeration attributes = servletContext.getAttributeNames(); 
    while (attributes.hasMoreElements()) {
      String attribute = (String) attributes.nextElement(); 
      System.out.println("Attribute name : " + attribute); 
      System.out.println("Attribute value : " + 
        servletContext.getAttribute(attribute)); 
    } 

    System.out.println("Major version : " + 
servletContext.getMajorVersion()); 
    System.out.println("Minor version : " + 
servletContext.getMinorVersion()); 
    System.out.println("Server info : " + servletContext.getServerInfo()); 
  } 

  public String getServletInfo() {
    return null; 
  } 
  public ServletConfig getServletConfig() {
    return null; 
  } 

}&lt;/pre&gt;&lt;div class="docText"&gt;The output of the code is as follows. This output may be  different on your computer, depending on the version of Tomcat you are using,  the operating system, and so on.&lt;/div&gt;&lt;pre&gt;Attribute name : javax.servlet.context.tempdirAttribute value : 
..\work\localhost\myApp 
Attribute name : org.apache.catalina.resources 
Attribute value : org.apache.naming.resources.ProxyDirContext@24e2e3 
Attribute name : org.apache.catalina.WELCOME_FILES 
Attribute value : [Ljava.lang.String;@2bb7e0 
Attribute name : org.apache.catalina.jsp_classpath 
Attribute value : C:\tomcat4\webapps\myApp\WEB-INF\classes; 
. 
. 
. Major version : 2Minor version : 3 
Server info : Apache Tomcat/4.0-b5&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-2289294097006999377?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/2289294097006999377/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2289294097006999377?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2289294097006999377?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0MERXc5fip7ImA9WhZXFEw.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-1616740899601646723</id><published>2011-04-30T22:45:00.001+05:30</published><updated>2011-05-03T15:06:44.926+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-03T15:06:44.926+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Preserving the ServletConfig'/><title>Preserving the ServletConfig</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;The code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.3&lt;/a&gt;  shows how you can use the ServletConfig object in the init method. Sometimes,  however, you may want more flexibility. For example, you may want to have access  to the ServletConfig object from the service method, when you are servicing the  user. In this case, you need to preserve the ServletConfig object to a class  level variable. This task is not difficult. You need to create a ServletConfig  object variable and set it to the ServletConfig object returned by the servlet  container in the init method.&lt;/div&gt;&lt;div class="docText"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.4&lt;/a&gt; gives the  code that preserves the ServletConfig object for later use. First, you need a  variable for the ServletConfig object.&lt;/div&gt;&lt;pre&gt;ServletConfig servletConfig;&lt;/pre&gt;&lt;div class="docText"&gt;Then, in the init method, you write the following code:&lt;/div&gt;&lt;pre&gt;servletConfig = config;&lt;/pre&gt;&lt;div class="docText"&gt;Now the servletConfig variable references the ServletConfig  object returned by the servlet container. The getServletConfig method is  provided to do just that: return the ServletConfig object.&lt;/div&gt;&lt;pre&gt;public ServletConfig getServletConfig() {
  return servletConfig; 
}&lt;/pre&gt;&lt;div class="docText"&gt;If you extend the ReserveConfigServlet class, you can still  retrieve the ServlerConfig object by calling the getServletConfig method.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list04"&gt;Listing 2.4 Preserving the ServletConfig  Object&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.IOException; 

public class ReserveConfigServlet implements Servlet {
  ServletConfig servletConfig; 

  public void init(ServletConfig config) throws ServletException {
    servletConfig = config; 
  } 

  public void destroy() {
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {
  } 

  public String getServletInfo() {
    return null; 
  } 

  public ServletConfig getServletConfig() {
    return servletConfig; 
  } 

}&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-1616740899601646723?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/1616740899601646723/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1616740899601646723?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1616740899601646723?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0MERXc5fyp7ImA9WhZXFEw.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-8669270762432405598</id><published>2011-04-30T22:44:00.001+05:30</published><updated>2011-05-03T15:06:44.927+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-03T15:06:44.927+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Obtaining Configuration Information'/><title>Obtaining Configuration Information</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;The servlet specification allows you to configure your  application. You'll find more information on this topic in the discussion of the  deployment descriptor in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Chapter  16&lt;/a&gt;, "Application Deployment." In this chapter, I present an example that  demonstrates how you can retrieve configuration information from the application  web.xml file.&lt;/div&gt;&lt;div class="docText"&gt;For each servlet registered in the web.xml file, you have the  option of specifying a set of initial parameter name/value pairs that you can  retrieve from inside the servlet. The following web.xml file contains a servlet  called ConfigDemo whose class is named ConfigDemoServlet.class. The servlet has  two initial parameter name/value pairs. The first parameter is named adminEmail  and its value is &lt;tt&gt;admin@brainysoftware.com&lt;/tt&gt;. The second parameter is  named adminContactNumber and the value for this parameter is 04298371237.&lt;/div&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="ISO-8859-1"?&amp;gt; 
&amp;lt;!DOCTYPE web-app 
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" 
    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd"&amp;gt; 

&amp;lt;web-app&amp;gt; 
  &amp;lt;servlet&amp;gt; 
    &amp;lt;servlet-name&amp;gt;ConfigDemo&amp;lt;/servlet-name&amp;gt; 
    &amp;lt;servlet-class&amp;gt;ConfigDemoServlet&amp;lt;/servlet-class&amp;gt; 
    &amp;lt;init-param&amp;gt; 
      &amp;lt;param-name&amp;gt;adminEmail&amp;lt;/param-name&amp;gt; 
      &amp;lt;param-value&amp;gt;admin@brainysoftware.com&amp;lt;/param-value&amp;gt; 
    &amp;lt;/init-param&amp;gt; 
    &amp;lt;init-param&amp;gt; 
      &amp;lt;param-name&amp;gt;adminContactNumber&amp;lt;/param-name&amp;gt; 
      &amp;lt;param-value&amp;gt;04298371237&amp;lt;/param-value&amp;gt; 
    &amp;lt;/init-param&amp;gt; 
  &amp;lt;/servlet&amp;gt; 
&amp;lt;/web-app&amp;gt;&lt;/pre&gt;&lt;div class="docText"&gt;Why would you want to use an initial parameter? For  practicality. Hardcoding information in the servlet code means that you have to  recompile the servlet if the information changes. A web.xml file is plain text.  You can edit its content easily using a text editor.&lt;/div&gt;&lt;div class="docText"&gt;The code that retrieves the initial parameter name and values  is given in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.3&lt;/a&gt;.&lt;/div&gt;&lt;div class="docText"&gt;To retrieve initial parameters, you need the ServletConfig  object passed by the servlet container to the servlet. After you get the  ServletConfig object, you then can use its getInitParameterNames and  getInitParameter methods. The getInitParameterNames does not take an argument  and returns an Enumeration containing all the parameter names in the  ServletConfig object. The getInitParameter takes a String containing the  parameter name and returns a String containing the value of the parameter.&lt;/div&gt;&lt;div class="docText"&gt;Because the servlet container passes a ServletConfig object to  the init method, it is easiest to write the code in the init method. The code in  &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.3&lt;/a&gt; loops through the  Enumeration object called parameters that is returned from the  getInitParameterNames method. For each parameter, it outputs the parameter name  and value. The parameter value is retrieved using the getInitParameter  method.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list03"&gt;Listing 2.3 Retrieving Initial  Parameters&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.util.Enumeration; 
import java.io.IOException; 

public class ConfigDemoServlet implements Servlet {

  public void init(ServletConfig config) throws ServletException {
    Enumeration parameters = config.getInitParameterNames(); 
    while (parameters.hasMoreElements()) {
      String parameter = (String) parameters.nextElement(); 
      System.out.println("Parameter name : " + parameter); 
      System.out.println("Parameter value : " + 
        config.getInitParameter(parameter)); 
    } 
  } 

  public void destroy() {
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {
  } 

  public String getServletInfo() {
    return null; 
  } 

  public ServletConfig getServletConfig() {
    return null; 
  } 
}&lt;/pre&gt;&lt;div class="docText"&gt;The output of the code in the console is as follows:&lt;/div&gt;&lt;pre&gt;Parameter name : adminContactNumber 
Parameter value : 04298371237 
Parameter name : adminEmail 
Parameter value : admin@brainysoftware.com&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-8669270762432405598?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/8669270762432405598/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8669270762432405598?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8669270762432405598?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0QGQHwyeyp7ImA9WhZXFEk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-2518893037441189658</id><published>2011-04-30T22:43:00.001+05:30</published><updated>2011-05-03T22:18:41.293+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-03T22:18:41.293+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Demonstrating the Life Cycle of a Servlet'/><title>Demonstrating the Life Cycle of a Servlet</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.1&lt;/a&gt; contains  the code for a servlet named PrimitiveServlet, a very simple servlet that exists  to demonstrate the life cycle of a servlet. The PrimitiveServlet class  implements javax.servlet.Servlet (as all servlets must) and provides  implementations for all the five methods of servlet. What it does is very  simple. Each time any of the init, service, or destroy methods is called, the  servlet writes the method's name to the console.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list01"&gt;Listing 2.1 PrimitiveServlet.java&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import java.io.IOException; 

public class PrimitiveServlet implements Servlet {

  public void init(ServletConfig config) throws ServletException {
    System.out.println("init"); 
  } 

  public void service(ServletRequest request, ServletResponse response) 
    throws ServletException, IOException {
    System.out.println("service"); 
  }   
  public void destroy() {
    System.out.println("destroy"); 
  } 

  public String getServletInfo() {
    return null; 
  } 
  public ServletConfig getServletConfig() {
    return null; 
  } 

}&lt;/pre&gt;&lt;div class="docText"&gt;After you compile the source code into the  myApp\WEB-INF\classes directory, add the servlet to the web.xml under the name  Primitive, as shown in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.2&lt;/a&gt;.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch02list02"&gt;Listing 2.2 The web.xml File for  PrimitiveServlet&lt;/h5&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="ISO-8859-1"?&amp;gt; 

&amp;lt;!DOCTYPE web-app 
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
  "http://java.sun.com/dtd/web-app_2_3.dtd"&amp;gt; 

&amp;lt;web-app&amp;gt; 
  &amp;lt;servlet&amp;gt; 
    &amp;lt;servlet-name&amp;gt;Primitive&amp;lt;/servlet-name&amp;gt; 
    &amp;lt;servlet-class&amp;gt;PrimitiveServlet&amp;lt;/servlet-class&amp;gt; 
  &amp;lt;/servlet&amp;gt; 
&amp;lt;/web-app&amp;gt;&lt;/pre&gt;&lt;div class="docText"&gt;You should then be able to call this servlet from your browser  by typing the following URL:&lt;/div&gt;&lt;pre&gt;http://localhost:8080/myApp/servlet/Primitive&lt;/pre&gt;&lt;div class="docText"&gt;The first time the servlet is called, the console displays  these two lines:&lt;/div&gt;&lt;pre&gt;init 
service&lt;/pre&gt;&lt;div class="docText"&gt;This tells you that the init method is called, followed by the  service method. However, on subsequent requests, only the service method is  called. The servlet adds the following line to the console:&lt;/div&gt;&lt;pre&gt;service&lt;/pre&gt;&lt;div class="docText"&gt;This proves that the init method is called only once.&lt;/div&gt;&lt;div class="docText"&gt;What are the getServletInfo and getServletConfig doing in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 2.1&lt;/a&gt; ? Nothing. They can be useful,  but in the PrimitiveServlet class, they are just there to meet the specification  that a class must provide implementations for all methods in the interface it  implements.&lt;/div&gt;&lt;div class="docText"&gt;You can return any string in the getServletInfo method, such as  your company name or the author name or other information deemed necessary.  Other people might extend your servlet class and might want to know what useful  information the designer of the servlet has provided.&lt;/div&gt;&lt;div class="docText"&gt;The getServletConfig is more important. We will see how it can  be of use next&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-2518893037441189658?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/2518893037441189658/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2518893037441189658?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2518893037441189658?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0QGQHwyeyp7ImA9WhZXFEk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-7613372280287899483</id><published>2011-04-30T22:42:00.001+05:30</published><updated>2011-05-03T22:18:41.293+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-03T22:18:41.293+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='A Servlet&apos;s Life Cycle'/><title>A Servlet's Life Cycle</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;Let there be servlet. This interface in the javax.servlet  package is the source of all activities in servlet programming. Servlet is the  central abstraction of the Java servlet technology. Every servlet you write must  implement this javax.servlet.Servlet interface, either directly or indirectly.  The life cycle of a servlet is determined by three of its methods: init,  service, and destroy.&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch02lev2sec1"&gt;The init( ) Method&lt;/h4&gt;&lt;div class="docText"&gt;The init method is called by the servlet container after the  servlet class has been instantiated. The servlet container calls this method  exactly once to indicate to the servlet that the servlet is being placed into  service. The init method must complete successfully before the servlet can  receive any requests.&lt;/div&gt;&lt;div class="docText"&gt;You can override this method to write initialization code that  needs to run only once, such as loading a database driver, initializing values,  and so on. In other cases, you normally leave this method blank.&lt;/div&gt;&lt;div class="docText"&gt;The signature of this method is as follows:&lt;/div&gt;&lt;pre&gt;public void init(ServletConfig config) throws ServletException&lt;/pre&gt;&lt;div class="docText"&gt;The init method is important also because the servlet container  passes a ServletConfig object, which contains the configuration values stated in  the web.xml file for this application. More on ServletConfig can be found later  in this chapter, in the section, "&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Obtaining Configuration Information&lt;/a&gt;."&lt;/div&gt;&lt;div class="docText"&gt;This method also can throw a ServletException. The servlet  container cannot place the servlet into service if the init method throws a  ServletException or the method does not return within a time period defined by  the web server.&lt;/div&gt;&lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Note&lt;/div&gt;&lt;div class="docText"&gt;ServletException is the most important exception in servlet  programming. In fact, a lot of methods in the javax.servlet and  javax.servlet.http packages can throw this exception when a problem exists in a  servlet.&lt;/div&gt;&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch02lev2sec2"&gt;The service( ) Method&lt;/h4&gt;&lt;div class="docText"&gt;The service method is called by the servlet container after the  servlet's init method to allow the servlet to respond to a request.&lt;/div&gt;&lt;div class="docText"&gt;Servlets typically run inside multithreaded servlet containers  that can handle multiple requests concurrently. Therefore, you must be aware to  synchronize access to any shared resources, such as files, network connections,  and the servlet's class and instance variables. For example, if you open a file  and write to that file from a servlet, you need to remember that a different  thread of the same servlet also can open the same file. See the section, "&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Creating Thread-Safe Servlets&lt;/a&gt;," for more  on the topic of multithreading and synchronization.&lt;/div&gt;&lt;div class="docText"&gt;This method has the following signature:&lt;/div&gt;&lt;pre&gt;public void service(ServletRequest request, ServletResponse response) 
  throws ServletException, java.io.IOException&lt;/pre&gt;&lt;div class="docText"&gt;The servlet container passes a ServletRequest object and the  ServletResponse object. The ServletRequest object contains the client's request  and the ServletResponse contains the servlet's response. These two objects are  important because they enable you to write custom code that determines how the  servlet services the client request.&lt;/div&gt;&lt;div class="docText"&gt;The service method throws a ServletException if an exception  occurs that interferes with the servlet's normal operation. The service method  also can throw a java.io.IOException if an input or output exception occurs  during the execution of this method.&lt;/div&gt;&lt;div class="docText"&gt;As the name implies, the service method exists so that you can  write code that makes the servlet function the way it is supposed to.&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch02lev2sec3"&gt;The destroy( ) Method&lt;/h4&gt;&lt;div class="docText"&gt;The servlet container calls the destroy method before removing  a servlet instance from service. This normally happens when the servlet  container is shut down or the servlet container needs some free memory.&lt;/div&gt;&lt;div class="docText"&gt;This method is called only after all threads within the  servlet's service method have exited or after a timeout period has passed. After  the servlet container calls this method, it will not call the service method  again on this servlet.&lt;/div&gt;&lt;div class="docText"&gt;The destroy method gives the servlet an opportunity to clean up  any resources that are being held (for example, memory, file handles, and  threads) and make sure that any persistent state is synchronized with the  servlet's current state in memory.&lt;/div&gt;&lt;div class="docText"&gt;The signature of this method is as follows:&lt;/div&gt;&lt;pre&gt;public void destroy()&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-7613372280287899483?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/7613372280287899483/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/7613372280287899483?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/7613372280287899483?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0QGQHwyfCp7ImA9WhZXFEk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-2484999834739535354</id><published>2011-04-30T22:39:00.001+05:30</published><updated>2011-05-03T22:18:41.294+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-03T22:18:41.294+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='The javax.servlet Package'/><title>The javax.servlet Package</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;The javax.servlet package contains seven interfaces, three  classes, and two exceptions. Instead of using the conventional approach by  explaining each interface and class in alphabetical order—thus making the book  feel like a dictionary—I present the discussions based on functions and offer  examples that demonstrate each function.&lt;/div&gt;&lt;div class="docText"&gt;Nevertheless, mastering all the members of this package is  important. To help you, a complete reference is given in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Appendix B&lt;/a&gt;, "The javax.servlet Package  Reference."&lt;/div&gt;&lt;div class="docText"&gt;The seven interfaces are as follows:&lt;/div&gt;&lt;ul&gt;&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;RequestDispatcher&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Servlet&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;ServletConfig&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;ServletContext&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;ServletRequest&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;ServletResponse&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;SingleThreadModel&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="docText"&gt;The three classes are as follows:&lt;/div&gt;&lt;ul&gt;&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;GenericServlet&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;ServletInputStream&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;ServletOutputStream&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="docText"&gt;And, finally, the exception classes are these:&lt;/div&gt;&lt;ul&gt;&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;ServletException&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li&gt; &lt;div class="docList"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;UnavailableException&lt;/a&gt; &lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="docText"&gt;The object model of the javax.servlet package is shown in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 2.1&lt;/a&gt;.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch02fig01"&gt;Figure 2.1. The javax.servlet package  object model.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-YAGj51zrugM/TbxC1zIKW1I/AAAAAAAAAAc/tfjrSF5rPSw/s1600/aaa.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="408" src="http://3.bp.blogspot.com/-YAGj51zrugM/TbxC1zIKW1I/AAAAAAAAAAc/tfjrSF5rPSw/s640/aaa.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="docText"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/center&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-2484999834739535354?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/2484999834739535354/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2484999834739535354?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/2484999834739535354?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-YAGj51zrugM/TbxC1zIKW1I/AAAAAAAAAAc/tfjrSF5rPSw/s72-c/aaa.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0QGQHwyfCp7ImA9WhZXFEk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-1900685673821902961</id><published>2011-04-30T22:38:00.001+05:30</published><updated>2011-05-03T22:18:41.294+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-03T22:18:41.294+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Inside Servlets'/><title>Inside Servlets</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;Watching your servlet in action, as you did in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Chapter 1&lt;/a&gt;, "The Servlet Technology," should bring  you confidence. And, as some people say, having confidence is half the battle in  learning anything. To be an expert, however, you need to understand the nuts and  bolts of the Java Servlet specification Application Programming Interface (API).  This book has been written using the latest release of the servlet specification  API—version 2.3. Two packages are available for servlet programmers:  javax.servlet and javax.servlet.http. The first one contains basic classes and  interfaces that you can use to write servlets from the scratch. The second  package, javax.servlet.http, offers more advanced classes and interfaces that  extend classes and interfaces from the first package. It is much more convenient  to program using the second package.&lt;/div&gt;&lt;div class="docText"&gt;When you learn something, it is best to start with the basics  and build a strong foundation. For example, understanding the  javax.servlet.Servlet interface is very important because it encapsulates the  life cycle methods of a servlet and it is the interface that all servlets must  implement. You also need to know the servlet's context, which represents a  servlet's environment, and the servlet's configuration. Because of the  importance of these items, this chapter introduces you to members of the  javax.servlet package. In this chapter, you also will see that oftentimes  several ways exist to do the same thing.&lt;/div&gt;&lt;div class="docText"&gt;After a few examples, I will introduce you to the  GenericServlet class, a member of the javax.servlet package that acts as a  wrapper for the javax.servlet.Servlet interface. Extending this class makes your  code simpler because you need to provide implementations only for methods that  you need to use.&lt;/div&gt;&lt;div class="docText"&gt;To run each example in this chapter, you need to compile the  source code and copy the resulting class file into the classes directory under  the WEB-INF directory of your application. Refer to &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Chapter 1&lt;/a&gt; if you have forgotten the six steps you  need to run your servlet.&lt;/div&gt;&lt;div class="docText"&gt;The rest of this chapter explains and uses the interfaces and  classes of the javax.servlet package. The chapters that follow focus more on the  second package&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-1900685673821902961?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/1900685673821902961/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1900685673821902961?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1900685673821902961?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0QGQHwyfCp7ImA9WhZXFEk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-484377100358744825</id><published>2011-04-30T22:32:00.001+05:30</published><updated>2011-05-03T22:18:41.294+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-03T22:18:41.294+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Six Steps to Running Your First Servlet'/><title>Six Steps to Running Your First Servlet</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;After you have installed and configured Tomcat, you can put it  into service. Basically, you need to follow six steps to go from writing your  servlet to running it. These steps are summarized as follows:&lt;/div&gt;&lt;span style="font-weight: bold;"&gt; &lt;ol class="docList"&gt;&lt;li&gt;&lt;span style="font-weight: normal;" value="1"&gt; &lt;div class="docList"&gt;Create a directory structure under Tomcat for your  application. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="2"&gt; &lt;div class="docList"&gt;Write the servlet source code. You need to import the  javax.servlet package and the javax.servlet.http package in your source  file. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="3"&gt; &lt;div class="docList"&gt;Compile your source code. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="4"&gt; &lt;div class="docList"&gt;Create a deployment descriptor. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="5"&gt; &lt;div class="docList"&gt;Run Tomcat. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="6"&gt; &lt;div class="docList"&gt;Call your servlet from a web browser.  &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/span&gt; &lt;div class="docText"&gt;The sections that follow walk you through each of these  steps.&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch01lev2sec1"&gt;Step 1: Create a Directory Structure  Under Tomcat&lt;/h4&gt;&lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Note&lt;/div&gt;&lt;div class="docText"&gt;The directory where Tomcat is installed is often referred to as  %CATALINA_HOME%. In previous versions of Tomcat, this directory was called  %TOMCAT_HOME%.&lt;/div&gt;&lt;/div&gt;&lt;div class="docText"&gt;When you install Tomcat, several subdirectories are  automatically created under the Tomcat home directory (%CATALINA_HOME%). One of  the subdirectories is webapps. The webapps directory is where you store your web  applications. A &lt;span class="docEmphasis"&gt;web application&lt;/span&gt; is a collection  of servlets and other content installed under a specific subset of the server's  URL namespace. A separate directory is dedicated for each servlet application.  Therefore, the first thing to do when you build a servlet application is create  an application directory. To create a directory structure for an application  called myApp, follow these steps:&lt;/div&gt;&lt;span style="font-weight: bold;"&gt; &lt;ol class="docList"&gt;&lt;li&gt;&lt;span style="font-weight: normal;" value="1"&gt; &lt;div class="docList"&gt;Create a directory called myApp under the webapps directory.  The directory name is important because this also appears in the URL to your  servlet. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight: normal;" value="2"&gt; &lt;div class="docList"&gt;Create the and WEB-INF directories under myApp, and create a  directory named classes under WEB-INF. The directory structure is shown in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 1.4&lt;/a&gt;. The directory classes under  WEB-INF is for your Java classes. If you have HTML files, put them directly  under the myApp directory. You may also want to create a directory called images  under myApp for all your image files.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch01fig04"&gt;Figure 1.4. Tomcat application directory  structure.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-jwqu8Ns74Rc/TbxBrIrkfeI/AAAAAAAAAAU/vBlojdA__4c/s1600/sss.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/-jwqu8Ns74Rc/TbxBrIrkfeI/AAAAAAAAAAU/vBlojdA__4c/s320/sss.JPG" width="172" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="docText"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/center&gt; &lt;div class="docList"&gt;Note that the examples, manager, ROOT, tomcat-doc, and webdav  directories are for applications that are created automatically when you install  Tomcat. &lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/span&gt; &lt;h4 class="docSection2Title" id="ch01lev2sec2"&gt;Step 2: Write the Servlet Source  Code&lt;/h4&gt;&lt;div class="docText"&gt;In this step, you prepare your source code. You can write the  source code yourself using your favorite text editor or copy it from the  accompanying CD.&lt;/div&gt;&lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Tip&lt;/div&gt;&lt;div class="docText"&gt;The source code for all examples in this book are also  available on the book's web site. Check out &lt;a class="docLink" href="http://www.newriders.com/" target="_blank"&gt;www.newriders.com&lt;/a&gt; to download  the files you need.&lt;/div&gt;&lt;/div&gt;&lt;div class="docText"&gt;The code in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Listing 1.1&lt;/a&gt;  shows a simple servlet called TestingServlet. The file is named  TestingServlet.java. The servlet sends a few HTML tags and some text to the  browser. For now, don't worry if you haven't got a clue about how it works.&lt;/div&gt;&lt;h5 class="docExampleTitle" id="ch01list01"&gt;Listing 1.1 TestingServlet.java&lt;/h5&gt;&lt;pre&gt;import javax.servlet.*; 
import javax.servlet.http.*; 
import java.io.*; 
import java.util.*; 

public class TestingServlet extends HttpServlet {

  public void doGet(HttpServletRequest request, 
    HttpServletResponse response) 
    throws ServletException, IOException {

    PrintWriter out = response.getWriter(); 
    out.println("&amp;lt;HTML&amp;gt;"); 
    out.println("&amp;lt;HEAD&amp;gt;"); 
    out.println("&amp;lt;TITLE&amp;gt;Servlet Testing&amp;lt;/TITLE&amp;gt;"); 
    out.println("&amp;lt;/HEAD&amp;gt;"); 
    out.println("&amp;lt;BODY&amp;gt;"); 
    out.println("Welcome to the Servlet Testing Center"); 
    out.println("&amp;lt;/BODY&amp;gt;"); 
    out.println("&amp;lt;/HTML&amp;gt;"); 
  } 
}&lt;/pre&gt;&lt;div class="docText"&gt;Now, save your TestingServlet.java file to the WEB-INF/classes  directory under myApp. Placing your source code here will make it inaccessible  from a web browser. Static files, such as HTML files and image files, should be  placed directly under the myApp directory or a directory under it.&lt;/div&gt;&lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Warning&lt;/div&gt;&lt;div class="docText"&gt;Placing your source code files outside the WEB-INF directory  will make them viewable from a browser.&lt;/div&gt;&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch01lev2sec3"&gt;Step 3: Compile Your Source Code&lt;/h4&gt;&lt;div class="docText"&gt;For your servlet source code to compile, you need to include  the path to the servlet.jar file in your CLASSPATH environment variable. The  servlet.jar is located in the common\lib\ subdirectory under  %CATALINA_HOME%.&lt;/div&gt;&lt;div class="docText"&gt;For example, if you installed Tomcat under the C:\drive on  Windows and you named the install directory tomcat, type the following command  from the directory where TestingServlet.java resides.&lt;/div&gt;&lt;pre&gt;javac classpath C:\tomcat\common\lib\servlet.jar TestingServlet.java&lt;/pre&gt;&lt;div class="docText"&gt;Alternatively, to save you typing the class path every time you  compile your source code, you can add the complete path to the servlet.jar file  to your CLASSPATH environment variable. Again, if you have installed Tomcat  under C:\and named the install directory tomcat, you must add C:\tomcat\  common\lib\servlet.jar to the CLASSPATH environment variable. Afterward, you can  compile your source by simply typing the following.&lt;/div&gt;&lt;pre&gt;javac TestingServlet.java&lt;/pre&gt;&lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Note&lt;/div&gt;&lt;div class="docText"&gt;If you have forgotten how to edit the CLASSPATH environment  variable, refer to &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Appendix  A&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="docText"&gt;If you are using Windows, remember that the new environment  variable takes effect only for new console windows. In other words, after  changing a new environment variable, open a new console window for typing in  your command lines.&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch01lev2sec4"&gt;Step 4: Create the Deployment  Descriptor&lt;/h4&gt;&lt;div class="docText"&gt;A deployment descriptor is an optional component in a servlet  application. The descriptor takes the form of an XML document called web.xml and  must be located in the WEB-INF directory of the servlet application. When  present, the deployment descriptor contains configuration settings specific to  that application. Deployment descriptors are discussed in detail in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Chapter 16&lt;/a&gt;.&lt;/div&gt;&lt;div class="docText"&gt;To create the deployment descriptor, you now need to create a  web.xml file and place it under the WEB-INF directory under myApp.&lt;/div&gt;&lt;div class="docText"&gt;The web.xml for this example application must have the  following content.&lt;/div&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="ISO-8859-1"?&amp;gt; 

&amp;lt;!DOCTYPE web-app 
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
  "http://java.sun.com/dtd/web-app_2_3.dtd"&amp;gt; 

&amp;lt;web-app&amp;gt; 
  &amp;lt;servlet&amp;gt; 
    &amp;lt;servlet-name&amp;gt;Testing&amp;lt;/servlet-name&amp;gt; 
    &amp;lt;servlet-class&amp;gt;TestingServlet&amp;lt;/servlet-class&amp;gt; 
  &amp;lt;/servlet&amp;gt; 
&amp;lt;/web-app&amp;gt;&lt;/pre&gt;&lt;div class="docText"&gt;The web.xml file has one element—web-app. You should write all  your servlets under &amp;lt;web-app&amp;gt;. For each servlet, you have a  &amp;lt;servlet&amp;gt; element and you need the &amp;lt;servlet-name&amp;gt; and  &amp;lt;servlet-class&amp;gt; elements. The &amp;lt;servlet-name&amp;gt; is the name for your  servlet, by which it is known Tomcat. The &amp;lt;servlet-class&amp;gt; is the compiled  file of your servlet without the .class extension.&lt;/div&gt;&lt;div class="docText"&gt;Having more than one servlet in an application is very common.  For every servlet, you need a &amp;lt;servlet&amp;gt; element in the web.xml file. For  example, the following shows you how web.xml looks if you add another servlet  called Login:&lt;/div&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="ISO-8859-1"?&amp;gt; 

&amp;lt;!DOCTYPE web-app 
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
  "http://java.sun.com/dtd/web-app_2_3.dtd"&amp;gt; 

&amp;lt;web-app&amp;gt; 
  &amp;lt;servlet&amp;gt; 
    &amp;lt;servlet-name&amp;gt;Testing&amp;lt;/servlet-name&amp;gt; 
    &amp;lt;servlet-class&amp;gt;TestingServlet&amp;lt;/servlet-class&amp;gt; 
  &amp;lt;/servlet&amp;gt; 
  &amp;lt;servlet&amp;gt; 
    &amp;lt;servlet-name&amp;gt;Login&amp;lt;/servlet-name&amp;gt; 
    &amp;lt;servlet-class&amp;gt;LoginServlet&amp;lt;/servlet-class&amp;gt; 
  &amp;lt;/servlet&amp;gt; 
&amp;lt;/web-app&amp;gt;&lt;/pre&gt;&lt;h4 class="docSection2Title" id="ch01lev2sec5"&gt;Step 5: Run Tomcat&lt;/h4&gt;&lt;div class="docText"&gt;If Tomcat is not already running, you need to start it. See &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Appendix A&lt;/a&gt; for information on how to  start or run Tomcat.&lt;/div&gt;&lt;h4 class="docSection2Title" id="ch01lev2sec6"&gt;Step 6: Call Your Servlet from a Web  Browser&lt;/h4&gt;&lt;div class="docText"&gt;Now, you can call your servlet from a web browser. By default,  Tomcat runs on port 8080 in the myApp virtual directory under the servlet  subdirectory. The servlet that you wrote in the preceding steps is named  Testing. The URL for that servlet has the following format:&lt;/div&gt;&lt;pre&gt;http://domain-name/virtual-directory/servlet/servlet-name&lt;/pre&gt;&lt;div class="docText"&gt;Any static file can be accessed using the following URL:&lt;/div&gt;&lt;pre&gt;http://domain-name/virtual-directory/staticFile.html&lt;/pre&gt;&lt;div class="docText"&gt;For example, a Logo.gif file under the myApp/images/ directory  can be accessed using the following URL.&lt;/div&gt;&lt;pre&gt;http://domain-name/virtual-directory/images/Logo.gif&lt;/pre&gt;&lt;div class="docText"&gt;If you run the web browser from the same computer as Tomcat,  you can replace the &lt;span class="docEmphasis"&gt;domain-name&lt;/span&gt; part with  "localhost". In that case, the URL for your servlet is&lt;/div&gt;&lt;pre&gt;http://localhost:8080/myApp/servlet/Testing&lt;/pre&gt;&lt;div class="docText"&gt;In the deployment descriptor you wrote in Step 4, you actually  mapped the servlet class file called TestingServlet with the name "Testing," so  that your servlet can be called by specifying its class file (TestingServlet) or  its name (Testing). Without a deployment descriptor, you must call the servlet  by specifying its class name; that is, TestingServlet. This means that if you  did not write a deployment descriptor in Step 4, you need to use the following  URL to call your servlet:&lt;/div&gt;&lt;pre&gt;http://localhost:8080/myApp/servlet/TestingServlet&lt;/pre&gt;&lt;div class="docText"&gt;Typing the URL in the Address or Location box of your web  browser will give you the string "Welcome to the Servlet Testing Center," as  shown in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 1.5&lt;/a&gt;.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch01fig05"&gt;Figure 1.5. The Testing servlet.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-zOt8dKJwmO0/TbxB3k9_eyI/AAAAAAAAAAY/ReI-VcQcwhQ/s1600/sssssss.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="172" src="http://4.bp.blogspot.com/-zOt8dKJwmO0/TbxB3k9_eyI/AAAAAAAAAAY/ReI-VcQcwhQ/s320/sssssss.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="docText"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/center&gt; &lt;div class="docText"&gt;Congratulations. You have just written your first servlet.&lt;/div&gt;&lt;div class="docText"&gt;If you don't want to type the port number each time, you can  change the default port of Tomcat so that it runs on port 80, the default port  for a web server. (Details on how to change the port number can be found in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Appendix A&lt;/a&gt;.) However, the rest of the  book will use Tomcat's default port 8080.&lt;/div&gt;&lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Note&lt;/div&gt;&lt;div class="docText"&gt;You will find code for various servlets in this chapter and the  next. To run each individual servlet, you need to repeat these six steps. To  avoid repetition, I do not mention these steps for every servlet presented in  this book. You don't need to worry about these steps if you are using a Java  development tool, such as Borland's JBuilder or IBM's VisualAge, because those  steps are taken care of by the RAD program.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-484377100358744825?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/484377100358744825/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/484377100358744825?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/484377100358744825?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-jwqu8Ns74Rc/TbxBrIrkfeI/AAAAAAAAAAU/vBlojdA__4c/s72-c/sss.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D08ARng-eCp7ImA9WhZXFEU.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-8188837944560955457</id><published>2011-04-30T22:31:00.001+05:30</published><updated>2011-05-04T10:40:47.650+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-04T10:40:47.650+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='The Tomcat Servlet Container'/><title>The Tomcat Servlet Container</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;A number of servlet containers are available today. The most  popular one—and the one recognized as the official servlet/JSP container—is  Tomcat. Originally designed by Sun Microsystems, Tomcat source code was handed  over to the Apache Software Foundation in October 1999. In this new home, Tomcat  was included as part of the Jakarta Project, one of the projects of the Apache  Software Foundation. Working through the Apache process, Apache, Sun, and other  companies—with the help of volunteer programmers worldwide—turned Tomcat into a  world-class servlet reference implementation. Two months after the handover,  Tomcat version 3.0 was released. Tomcat went through several 3.&lt;span class="docEmphasis"&gt;x&lt;/span&gt; releases until version 3.3 was introduced.&lt;/div&gt;&lt;div class="docText"&gt;The successor of version 3.3 is the current version, version  4.0. The 4.0 servlet container (Catalina) is based on a completely new  architecture and has been developed from the ground up for flexibility and  performance. Version 4.0 implements the Servlet 2.3 and JSP 1.2 specifications,  and it is this version you will be using in this book.&lt;/div&gt;&lt;div class="docText"&gt;Another popular servlet container is JRun from Allaire  Corporation. JRun is available in three editions: Developer, Professional, and  Enterprise. The Developer edition is free but not licensed for deployment. The  Professional and Enterprise editions grant you the license for deployment with a  fee. You can download JRun from &lt;a class="docLink" href="http://commerce.allaire.com/download" target="_blank"&gt;http://commerce.allaire.com/download&lt;/a&gt;.&lt;/div&gt;&lt;div class="docText"&gt;Tomcat by itself is a web server. This means that you can use  Tomcat to service HTTP requests for servlets, as well as static files (HTML,  image files, and so on). In practice, however, since it is faster for  non-servlet, non-JSP requests, Tomcat normally is used as a module with another  more robust web server, such as Apache web server or Microsoft Internet  Information Server. Only requests for servlets or JSP pages are passed to  Tomcat.&lt;/div&gt;&lt;div class="docText"&gt;To write a servlet, you need at least version 1.2 of the Java  Development Kit. If you have not already downloaded one, you can download JDK  1.2 from &lt;a class="docLink" href="http://java.sun.com/j2se" target="_blank"&gt;http://java.sun.com/j2se&lt;/a&gt;. The reference implementation for  both servlets and JSP are not included in J2SE, but they are included in Tomcat.  Tomcat is written purely in Java.&lt;/div&gt;&lt;div class="docText"&gt;If you haven't yet installed and configured Tomcat, now's the  time to do it. If you need help with these tasks, refer to &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Appendix A&lt;/a&gt; for specific steps.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-8188837944560955457?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/8188837944560955457/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8188837944560955457?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8188837944560955457?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D08ARng-eCp7ImA9WhZXFEU.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-5181794051439515338</id><published>2011-04-30T22:27:00.001+05:30</published><updated>2011-05-04T10:40:47.650+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-04T10:40:47.650+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='How a Servlet Works'/><title>How a Servlet Works</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;A servlet is loaded by the servlet container the first time the  servlet is requested. The servlet then is forwarded the user request, processes  it, and returns the response to the servlet container, which in turn sends the  response back to the user. After that, the servlet stays in memory waiting for  other requests—it will not be unloaded from the memory unless the servlet  container sees a shortage of memory. Each time the servlet is requested,  however, the servlet container compares the timestamp of the loaded servlet with  the servlet class file. If the class file timestamp is more recent, the servlet  is reloaded into memory. This way, you don't need to restart the servlet  container every time you update your servlet.&lt;/div&gt;&lt;div class="docText"&gt;The way in which a servlet works inside the servlet container  is depicted in the diagram in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure  1.3&lt;/a&gt;.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch01fig03"&gt;Figure 1.3. How a servlet works.&lt;/h5&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-l7W2FFnSioc/TbxAOp1yH4I/AAAAAAAAAAQ/vq-CdMbaUvU/s1600/sssss.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/-l7W2FFnSioc/TbxAOp1yH4I/AAAAAAAAAAQ/vq-CdMbaUvU/s320/sssss.JPG" width="204" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="docText"&gt;&lt;/div&gt;&lt;/center&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-5181794051439515338?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/5181794051439515338/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/5181794051439515338?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/5181794051439515338?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-l7W2FFnSioc/TbxAOp1yH4I/AAAAAAAAAAQ/vq-CdMbaUvU/s72-c/sssss.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D08ARng-eSp7ImA9WhZXFEU.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-3143035789696830571</id><published>2011-04-30T22:25:00.003+05:30</published><updated>2011-05-04T10:40:47.651+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-05-04T10:40:47.651+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Servlet Application Architecture'/><title>Servlet Application Architecture</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="docText"&gt;A servlet is a Java class that can be loaded dynamically into  and run by a special web server. This servlet-aware web server is called a &lt;span class="docEmphasis"&gt;servlet container&lt;/span&gt;, which also was called a &lt;span class="docEmphasis"&gt;servlet engine&lt;/span&gt; in the early days of the servlet  technology.&lt;/div&gt;&lt;div class="docText"&gt;Servlets interact with clients via a request-response model  based on HTTP. Because servlet technology works on top of HTTP, a servlet  container must support HTTP as the protocol for client requests and server  responses. However, a servlet container also can support similar protocols, such  as HTTPS (HTTP over SSL) for secure transactions.&lt;/div&gt;&lt;div class="docText"&gt;&lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 1.1&lt;/a&gt; provides the  architecture of a servlet application.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch01fig01"&gt;Figure 1.1. The servlet application  architecture.&lt;/h5&gt;&lt;div class="docText"&gt;&lt;img alt="graphics/01fig01.gif" border="0" height="84" src="" width="409" /&gt;&lt;/div&gt;&lt;/center&gt; &lt;div class="docText"&gt;In a JSP application, the servlet container is replaced by a  JSP container. Both the servlet container and the JSP container often are  referred to as the &lt;span class="docEmphasis"&gt;web container&lt;/span&gt; or &lt;span class="docEmphasis"&gt;servlet/JSP container&lt;/span&gt;, especially if a web application  consists of both servlets and JSP pages.&lt;/div&gt;&lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Note&lt;/div&gt;&lt;div class="docText"&gt;You will learn more about servlet and JSP containers in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Chapter 8&lt;/a&gt;, "JSP Basics.&lt;/div&gt;&lt;/div&gt;&lt;div class="docText"&gt;As you can see in the &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure  1.1&lt;/a&gt;, a servlet application also can include static content, such as HTML  pages and image files. Allowing the servlet container to serve static content is  not preferable because the content is faster if served by a more robust HTTP  server, such as the Apache web server or Microsoft Internet Information Server.  As such, it is common practice to put a web server at the front to handle all  client requests. The web server serves static content and passes to the servlet  containers all client requests for servlets. &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Figure 1.2&lt;/a&gt; shows a more common architecture for a servlet  application.&lt;/div&gt;&lt;center&gt; &lt;h5 class="docFigureTitle" id="ch01fig02"&gt;Figure 1.2. The servlet application  architecture employing an HTTP server.&lt;/h5&gt;&lt;div class="docText"&gt;&lt;img alt="graphics/01fig02.gif" border="0" height="76" src="" width="487" /&gt;&lt;/div&gt;&lt;/center&gt; &lt;div class="docNote"&gt; &lt;div class="docNoteTitle"&gt;Caution&lt;/div&gt;&lt;div class="docText"&gt;A Java web application architecture employing a J2EE server is  different from the diagrams in Figures &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;1.1&lt;/a&gt; and &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;1.2&lt;/a&gt;. This  is discussed in &lt;a class="docLink" href="http://www.blogger.com/post-create.g?blogID=6918085394948865719"&gt;Chapter 28&lt;/a&gt;,  "Enterprise JavaBeans."&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-3143035789696830571?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/3143035789696830571/comments/default' title='Post Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/3143035789696830571?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/3143035789696830571?v=2'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUIBSXkyeSp7ImA9WhZXEU0.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-107165097442510875</id><published>2011-04-30T00:29:00.000+05:30</published><updated>2011-04-30T00:29:18.791+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-04-30T00:29:18.791+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='package event'/><title>Listing 3:   package event</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
Listing 3: &lt;br /&gt;
package event;&lt;br /&gt;
&lt;br /&gt;
import com.sun.java.swing.event.EventListenerList;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;* Abstract class that both consumes events and&lt;br /&gt;
&amp;nbsp;* forwards event to other consumers.&lt;br /&gt;
&amp;nbsp;* Generally used to filter the events by their&lt;br /&gt;
&amp;nbsp;* context and possibly some other data, so that&lt;br /&gt;
&amp;nbsp;* the other consumers get only the events they&lt;br /&gt;
&amp;nbsp;* are interested in.&lt;br /&gt;
&amp;nbsp;* The consume method needs to be implemented.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;br /&gt;
public abstract class EventFilter implements&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;EventConsumer, EventDistributor, Serializable&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;private EventListenerList myEventConsumer = null;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Constructor.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;public EventFilter () {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;myEventConsumer = new EventListenerList();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Abstract method that processes Events.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * This method needs to be implmented to&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * process each event when they are received.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param Event the event to be processed.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @see EventConsumer.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;public abstract void consume(Event event);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Add an event consumer.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @see EventDistributor.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;public void addEventConsumer(&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;EventConsumer consumer, String context)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;myEventConsumer.add(EventConsumer.class,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;consumer);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Remove an event consumer.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @see EventDistributor.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;public void removeEventConsumer(&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;EventConsumer consumer)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;myEventConsumer.remove(EventConsumer.class,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;consumer);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Call all consumers that have registered.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Helper method to walk the list of consumers&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * calling all of their consume methods.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param Event the event to be processed.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @see EventListenerList&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;protected void fireEventConsumer(Event newEvent)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;Object[] listeners =&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;myEventConsumer.getListenerList();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;for (int i = listeners.length-2;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i &amp;gt;= 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i -= 2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (listeners[i] == EventConsumer.class) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;((EventConsumer)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;listeners[i+1]).consume(newEvent);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-107165097442510875?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/107165097442510875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/listing-3-package-event.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/107165097442510875?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/107165097442510875?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/listing-3-package-event.html' title='Listing 3:   package event'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUMNQH89cCp7ImA9WhZXEU0.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-1268382354922101249</id><published>2011-04-30T00:28:00.000+05:30</published><updated>2011-04-30T00:28:11.168+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-04-30T00:28:11.168+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='package event'/><title>Listing 2: package event</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
Listing 2: &lt;br /&gt;
package event;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;* The interface used by any component that&lt;br /&gt;
&amp;nbsp;* distributes events to other consumers.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
public interface EventDistributor {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Add an Event Consumer to the existing set of&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * event consumers that will be called when an&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * event of the proper type is recieved.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param EventConsumer the consumer to be&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * added.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param String the context in which the event&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * consumer wants to be called.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;public void addEventConsumer(EventConsumer cons,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;String context);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Remove an Event Consumer from the existing&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * set of event consumers that will be called&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * when an event is processed.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param EventConsumer the consumer to be&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * removed.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;public void removeEventConsumer(EventConsumer c);&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-1268382354922101249?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/1268382354922101249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/listing-2-package-event.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1268382354922101249?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/1268382354922101249?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/listing-2-package-event.html' title='Listing 2: package event'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUMHSX07eip7ImA9WhZXEU0.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-3975423831518492727</id><published>2011-04-30T00:27:00.000+05:30</published><updated>2011-04-30T00:27:18.302+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-04-30T00:27:18.302+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='package event'/><title>package event Listing 1</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
Listing 1: &lt;br /&gt;
package event;&lt;br /&gt;
&lt;br /&gt;
import java.util.EventListener;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;* &amp;nbsp;Interface for anything that will consume events.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;br /&gt;
public interface EventConsumer&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;extends EventListener&lt;br /&gt;
&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;/**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Consume method processes events of interest.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param Event the event.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;public void consume(Event event);&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-3975423831518492727?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/3975423831518492727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/package-event-listing-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/3975423831518492727?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/3975423831518492727?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/package-event-listing-1.html' title='package event Listing 1'/><author><name>sarav</name><uri>http://www.blogger.com/profile/05897412519686923963</uri><email>noreply@blogger.com</email><gd:extendedProperty name='OpenSocialUserId' value='17949187970392645173'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;AkADQnw4fyp7ImA9WhZREUk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-6460935746493056526</id><published>2011-04-07T09:29:00.000+05:30</published><updated>2011-04-07T09:29:33.237+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-04-07T09:29:33.237+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='programs'/><title>Equals</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;public class Equals{&lt;br /&gt;
public static void main(String args[]){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Calculator c1=new Calculator();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Calculator c2=c1;//new Calculator();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(c1==c2){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; System.out.println("c1==c2");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("c1!=c2");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(c1.equals(c2)){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; System.out.println("c1.equals(c2)");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; System.out.println(" c1 not equal to (c2)");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-6460935746493056526?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/6460935746493056526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/equals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/6460935746493056526?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/6460935746493056526?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/equals.html' title='Equals'/><author><name>indian government</name><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;AkENQngyfyp7ImA9WhZREUk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-8590633626170634545</id><published>2011-04-07T09:28:00.000+05:30</published><updated>2011-04-07T09:28:13.697+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-04-07T09:28:13.697+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='programs'/><title>DEMO</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&amp;nbsp;class Math{&lt;br /&gt;
public static void main(String args[]){&lt;br /&gt;
&lt;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp; if(c1==c2){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; System.out.println("c1==c2");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("c1!=c2");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(c1.equals(c2)){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; System.out.println("c1.equals(c2)");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; System.out.println(" c1 not equal to (c2)");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
*/&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-8590633626170634545?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/8590633626170634545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/demo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8590633626170634545?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/8590633626170634545?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/demo.html' title='DEMO'/><author><name>indian government</name><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;AkEERHo5fSp7ImA9WhZREUk.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-5080077880393915723</id><published>2011-04-07T09:26:00.002+05:30</published><updated>2011-04-07T09:26:45.425+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-04-07T09:26:45.425+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='programs'/><title>Calculator</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;public class Calculator&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;public int add(int x,int y){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("From Add");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return x+y;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&amp;nbsp; int div(int x,int y){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("From div");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return x/y;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public int product(int x,int y){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("From product");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return x*y;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-5080077880393915723?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/5080077880393915723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/calculator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/5080077880393915723?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/5080077880393915723?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/04/calculator.html' title='Calculator'/><author><name>indian government</name><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CEYFQHc8fyp7ImA9WhZTGEg.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-7362296854993307479</id><published>2011-03-23T09:18:00.000+05:30</published><updated>2011-03-23T09:18:31.977+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-03-23T09:18:31.977+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Interview'/><title>Designing Of An Effective Resume</title><content type='html'>&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;i&gt;&lt;u&gt;‘&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Curriculum-Vitae&lt;/strong&gt;’ (C.V for short) is a brief account of your personal details, educational and professional qualifications and the jobs you have held. T is a British expression. The American term for the same is ‘&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Resume&lt;/strong&gt;’.&lt;/u&gt;&lt;/i&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;What should a C.V Do?&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;nbsp;It must highlight your potential and value to an employer&lt;/em&gt;.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Provide a framework&amp;nbsp;&lt;/em&gt;with which an interview can be designed.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Provide a vivid account of your achievements&lt;/em&gt;&amp;nbsp;as a student and as a professional along with the skills you would bring to an organization, in case you are hired.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; Although a C.V never ensures an employment, it should&amp;nbsp;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;at least arouse the employer’s interest&lt;/span&gt;&amp;nbsp;and get you an interview call.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;&lt;span id="more-203" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Lay out of a C.V&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;An effective C.V should be&amp;nbsp;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;visually appealing&lt;/span&gt;. That means it should appear&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;neat&lt;/strong&gt;&amp;nbsp;and&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;orderly&lt;/strong&gt;. It should be&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;clear, concise and easy to read&lt;/em&gt;. The way, in which the information is presented on paper, goes a long way in creating a favorable first impression.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Things to Remember&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;1. Make sure that you use&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;very good quality paper&lt;/strong&gt;&amp;nbsp;for your C.V and the covering letter that goes with it.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;2.&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Leave clear margins&lt;/strong&gt;&amp;nbsp;and be consistent while presenting your information.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;3. It should be&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;typed neatly&lt;/strong&gt;.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;4.&amp;nbsp; Be&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;nbsp;brief and to the point&lt;/strong&gt;. Do not use ‘ten’ words where ‘five’ will do. However substance should not be sacrificed for the sake of ‘brevity’. Right attributes and achievements should be mentioned and emphasized properly. It is important to present yourself as a valuable candidate for the job advertised.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;5. It is advisable to show the finished product to someone well meaning and knowledgeable. Be prepared to incorporate suggestions and changes if they enhance the quality of your C.V.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;6.&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;nbsp;Never give false information.&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;7.&amp;nbsp; It is of utmost importance to&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;understand the job requirements&lt;/strong&gt;&amp;nbsp;and your suitability for the post.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;8. Highlight areas, where you can contribute fruitfully and effectively, rather than harping on your aspirations.&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;Key Components of a C.V&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Given below are the main constituents of a Resume.&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;The Information given hereunder need not appear in the same order. Freshers and students may use the same sequence but working professionals may rearrange it to suit their preference and requirements.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;1. Personal Details&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Full Name&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Age/Date of Birth&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Place of Birth&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Sex/Gender&amp;nbsp; (Male/Female)&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Address for Correspondence&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Telephone Numbers (Landline/Mobile)&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Nationality (In case of overseas employment)&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Passport Number.&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; –Do-&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Driving License Number&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Health (Unless some serious ailment, it should be stated as sound/excellent)&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Personal Hobbies and Interests&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Preferred Location&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;2.&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;nbsp;Educational and Professional Qualifications&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;Note: – You may mention here your professional qualifications or your occupation. For example: Computer Engineer, Law Graduate, Chartered Accountant etc.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;Educational qualifications can be mentioned in the form of a table given below: -&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;Examination&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year&amp;nbsp;&amp;nbsp; &amp;nbsp;University&amp;nbsp;&amp;nbsp; &amp;nbsp;Percentage&amp;nbsp;&amp;nbsp; &amp;nbsp;Class/Div.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;It may be&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;written in the descending order&lt;/strong&gt;, i.e. from the highest degree to the S.S.C examination or in the ascending order, i.e. beginning from the secondary education to the highest qualification acquired by you. Below secondary level education is not to be mentioned.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;Any additional training, diplomas and special courses undertaken must find place after the main educational details have been given.&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;3. Career History&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;It is the most crucial information for the employer. If you are already employed or are looking for a change, you must provide information regarding the jobs you have held. Your present assignment, the work experience you have gathered, the responsibilities you have shouldered and the skills developed during the work span, all have to be mentioned here. You may have the best of qualifications but your hands on experience in the relevant field are of greater value to the employer.&lt;/div&gt;&lt;div style="color: black; font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px; line-height: 17px;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;POINTS TO REMEMBER&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;1. You should always&amp;nbsp;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;catalog your jobs in the reverse order&lt;/span&gt;. Begin with your present employment or the most recent one, as it is of greatest interest to the prospective employer.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;2.&amp;nbsp; Avoid the use of first person, if possible.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Work experience&lt;/strong&gt;&amp;nbsp;described under headings such as:&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Period&amp;nbsp; ——–From——-To—–&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Employer——Name of the Organization&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Designation————–&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Reporting To——-Name of the immediate Boss—-&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;And a&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Work Profile&lt;/strong&gt;&amp;nbsp;given as mentioned below: -&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;To assist the Departmental Head&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Time to time maintenance of electrical machines&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;•&amp;nbsp;&amp;nbsp; &amp;nbsp;Trouble-shooting problems arising in the shop floor machines etc.&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;Is not only more appealing; it gives a clear idea of the person’s work and responsibilities at a quick glance.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;3. The information should be so organized in this section that it gives a&lt;span style="color: #888888; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;nbsp;clear idea of your strengths&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;to the prospective employer.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;4. In case you have undertaken a number of similar jobs, enlist them under one section, if possible.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;5.&amp;nbsp;&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Salary&lt;/strong&gt;: – It is advisable&amp;nbsp;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;not to mention salary&amp;nbsp;&lt;/span&gt;at this point. At most an expected salary range can be mentioned.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;6.&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;References&lt;/strong&gt;&amp;nbsp;– These must be provided if asked by the employer. But you must seek permission from the persons whose names have been given as referees.&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;CONCLUSION&lt;/strong&gt;&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;Suggested above is the basic structure of curriculum vitae. There can be several variants of the above-mentioned information. One may reorganize various headings, choosing to begin with very little personal details and devoting more space to the career history and educational qualifications, one’s career objectives, work ethics, specialized skills etc.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;Actually for an experienced professional these elements should be highlighted and mentioned first of all, immediately after ‘The Name of the Person’. Other details can be given in the end.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;If you are a fresher and have no work experience to mention, then lay emphasis on your educational qualifications or any other achievements during the school and campus life.&lt;/div&gt;&lt;div style="color: black; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 4px; text-decoration: none;"&gt;The idea is, to present a well-rounded picture of yourself and the valuable differences you can make to the organization, you seek to join.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-7362296854993307479?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/7362296854993307479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/03/designing-of-effective-resume.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/7362296854993307479?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/7362296854993307479?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/03/designing-of-effective-resume.html' title='Designing Of An Effective Resume'/><author><name>indian government</name><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;AkUDQHc5fCp7ImA9WhZQEE4.&quot;'><id>tag:blogger.com,1999:blog-6918085394948865719.post-5750978989559109249</id><published>2011-03-12T10:58:00.001+05:30</published><updated>2011-04-17T16:34:31.924+05:30</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-04-17T16:34:31.924+05:30</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Servlet initialisation parameters'/><title>Servlet initialisation parameters</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: black; font-family: 'Times New Roman'; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="text-align: left;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br class="Apple-interchange-newline" /&gt;package com.ack.web.servlet;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;import java.io.IOException;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;import java.io.PrintWriter;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;import java.util.Enumeration;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;import javax.servlet.ServletException;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;import javax.servlet.http.HttpServlet;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;import javax.servlet.http.HttpServletRequest;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;import javax.servlet.http.HttpServletResponse;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;/**&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;* initialisation parameters inside the web.xml file&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;servlet&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;servlet-name&amp;gt;initialisation&amp;lt;/servlet-name&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;servlet-class&amp;gt;com.ack.web.servlet.ServletInitialisationParameters&amp;lt;/servlet-class&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;init-param&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;param-name&amp;gt;jdbcurl&amp;lt;/param-name&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;param-value&amp;gt;someurl&amp;lt;/param-value&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;/init-param&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;init-param&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;param-name&amp;gt;password&amp;lt;/param-name&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;param-value&amp;gt;bah&amp;lt;/param-value&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;/init-param&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;init-param&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;param-name&amp;gt;username&amp;lt;/param-name&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;param-value&amp;gt;foo&amp;lt;/param-value&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;/init-param&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;lt;/servlet&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;*/&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;public class ServletInitialisationParameters extends HttpServlet {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp;public void init() throws ServletException {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;String jdbcURL = getInitParameter( "jdbcurl" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;String username = getInitParameter( "username" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;String password = getInitParameter( "password" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;try {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;if( jdbcURL == null || username == null || password == null ) {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;StringBuffer buf = new StringBuffer( "you must specify the " );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;buf.append( " 'jdbcurl', 'username', 'password' init params to -&amp;gt; " );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;buf.append( getClass().getName() + " within you web.xml file" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String msg = buf.toString();&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println( buf );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;log( msg );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throw new ServletException( msg );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;else {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// possible get connection to database&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;catch( Exception ex ) {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;log( ex.toString() );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;throw new ServletException( ex.toString() );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;finally {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;// do any clean-up if you need to&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;log( "Completed Initialisation -&amp;gt;" + getClass().getName() );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp;public void doGet( HttpServletRequest req, HttpServletResponse res )&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;throws ServletException, IOException {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;res.setContentType( "text/html" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;PrintWriter pw = res.getWriter();&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;pw.println( "&amp;lt;h3&amp;gt;Servlet Initialisation Parameters&amp;lt;/h3&amp;gt;" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;pw.println( "&amp;lt;p&amp;gt;&amp;lt;hr noshade&amp;gt;&amp;lt;p&amp;gt;" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Enumeration e = getInitParameterNames();&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while( e.hasMoreElements() ) {&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;String paramName = (String) e.nextElement();&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;pw.println( "Initialisation Parameter: [ " );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;pw.println( paramName + " = " + getInitParameter( paramName ) );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;pw.println( " ]&amp;lt;br&amp;gt;" );&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;}&lt;/div&gt;&lt;br class="Apple-interchange-newline" /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6918085394948865719-5750978989559109249?l=freeprojectsdownload.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://freeprojectsdownload.blogspot.com/feeds/5750978989559109249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/03/servlet-initialisation-parameters.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/5750978989559109249?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6918085394948865719/posts/default/5750978989559109249?v=2'/><link rel='alternate' type='text/html' href='http://freeprojectsdownload.blogspot.com/2011/03/servlet-initialisation-parameters.html' title='Servlet initialisation parameters'/><author><name>indian government</name><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry></feed>