It2EDU

Saturday, October 29, 2016





Servlet is a java class implements server functionality. Java Servlet technology lets you define HTTP-specific
servlet classes. A servlet class extends the capabilities of servers that host
applications accessed by way of a request-response programming model. Although
servlets can respond to any type of request, they are commonly used to extend
the applications hosted by web servers. Java servlets are run inside the web
server. Servlets are used to build web applications.  
Actually Servlets are replacement of
CGI (Common gate way interfaces). In CGI every request creates an instance and
process the request.  So the server takes a lot burden and it is affected
on server efficiency and performance. 











Servlet
features and advantages:







  • Servlets are small platform independent java programs.

  • Used for developing web applications.

  • Robust, portable and secure.

  • Servlet are faster than others like CGI.

  • Servlets uses standard API that supported by many web servers.

  • Servlets executes within the address space of a web server.

  • Servlets does not create instances for each request.
















Discussion
about the servlet life cycle and methods:


The lifecycle of a servlet is controlled by the container in which the
servlet has been deployed. When a request is mapped to a servlet, the container
performs the following steps.




     
If an instance of the servlet does not exist, the web container Loads the
servlet class.


b    Creates an
instance of the servlet class.


c   
Initializes the servlet instance by calling the init method. Initialization is
covered in Creating and initializing a servlet.



2    Invokes the
service method, passing request and response objects. Service methods are
discussed in Writing Service methods.


If it needs to remove the servlet, the container finalizes the servlet by
calling the servlet’s destroy method.










The init() method:










The init() method is called during initialization phase of the servlet life
cycle. The Web container first maps the requested URL to the corresponding
servlet available in the Web container and then instantiates the servlet. The
Web container then creates an object of the ServletConfig interface, which
contains the startup configuration information, such as initialization
parameters of the servlet. The Web container then calls the init() method of
the servlet and passes the ServletConfig object to it. ServletException is thrown by init() method in the
context of web container doesn’t initialize the resources of servlet.







The service() method:








 The service() method is the
important method, it contains the operation code to process the request.

The servlet container calls the service() method to process the request and
generate response to the client. Each time the servlet receives the request and
process it and generates the response. This process is going on until it call
the destroy() method.

The service() method is breaks into doGet(),
doPost(),doDelete(),doOption(),doPut() and doTrace(). Most commonly used
methods are doGet() and doPost().

  








The destroy() method:





The destroy() method is called when we want to shut down the application.
When the destroy() method is called the servlet resources are removed from the
web container.

Servlet init() and destroy() methods called once during execution of a
servlet.









Below picture shows the servlet lifecycle:























See the below example for better understanding about servlet lifecycle
methods:



import java.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import
javax.servlet.http.HttpServletRequest;


import
javax.servlet.http.HttpServletResponse;


import java.io.PrintWriter;



/**

 * Servlet
implementation class ServletMethodsDemo


 */

@WebServlet("/ServletMethodsDemo")

public class ServletMethodsDemo extends HttpServlet {

      
private static final long serialVersionUID = 1L;

      


    private String name="Santosh kumar G";

   

    public void init()throws ServletException{

      
System.
out.println("init() method is executed");

    }

      


    public void destroy(){

      
System.
out.println("Destroy method executed");

    }



       /**

      
 *
@see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)


      
 */


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


             
//
TODO
Auto-generated method stub


             


             
//response.getWriter().append("Served
at: ").append(request.getContextPath());


             
response.setContentType("text/html");

             
PrintWriter
out =response.getWriter();

             
//to
print the content


             
out.println("<html><head>");

             
out.println("<title>Demo
Servlet(by"
);

             
out.println(name);

             
out.println(")</title>");

             
out.println("</head>");

             
out.println("<body><p>Demo
Servlet (by"
);

             
out.println(name);

             
out.println(")</p></body></html>");

             
out.close();

                          


      
}




      
/**

      
 *
@see
HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)


      
 */


      
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

             
// TODO Auto-generated method stub

             
doGet(
request, response);

      
}




}



We can override init(),destroy(),doGet() and doPost() methods in this
example.

When we start the servlet, it first calls the init method and then go to the
doGet() method and process the requests. Once the servlet instance removing
from the container destroy() method executes.



















Tuesday, October 25, 2016







 Functional
Keys and General Short cut keys













· 
F1 [Display Help]






· 
F2 [Rename the selected item]






· 
F3 [Search for a file or folder]






· 
F4 [Display the address bar list in File Explorer]






· 
F5 [Refresh the active window]






· 
F6 [Cycle through screen elements in a window or on the desktop]






· 
F10 [Activate the Menu bar in the active app]






· 
ALT + F4 [Close the active item, or exit the active app]






· 
ALT + ESC [Cycle through items in the order in which they were opened]






· 
ALT + underlined letter in menus and dialog box options [Perform the
command for that letter]






· 
ALT + ENTER [Display properties for the selected item]






· 
ALT + SPACEBAR [Open the shortcut menu for the active window]






· 
ALT + LEFT ARROW [Back]






· 
ALT + RIGHT ARROW [Forward]






· 
ALT + PAGE UP [Move up one screen]






· 
ALT + PAGE DOWN [Move down one screen]






· 
ALT + TAB [Switch between open apps (except desktop apps)]






· 
CTRL + F4 [Close the active document (in apps that allow you to have
multiple documents open simultaneously)]






· 
CTRL + A [Select all items in a document or window]






· 
CTRL + C or CTRL + INSERT [Copy the selected item]






· 
CTRL + D / DELETE [DELETE the selected item and move it to the Recycle
Bin]






· 
CTRL + R or F5 [Refresh the active window]






· 
CTRL + V or SHIFT + INSERT [Paste the selected item]






· 
CTRL + X [Cut the selected item]






· 
CTRL + Y [Redo an action]






· 
CTRL + Z [Undo an action]






· 
CTRL + + or CTRL + – [Zoom in or out of a large NUMBER of items, like
apps pinned to the Start screen]






· 
CTRL + mouse scroll wheel [Change the size of desktop icons or zoom in
or out of a large NUMBER of items, like apps pinned to the Start screen]






· 
CTRL + RIGHT ARROW [Move the cursor to the beginning of the next word]






· 
CTRL + LEFT ARROW [Move the cursor to the beginning of the previous
word]






· 
CTRL + DOWN ARROW [Move the cursor to the beginning of the next
paragraph]






· 
CTRL + UP ARROW [Move the cursor to the beginning of the previous
paragraph]






· 
CTRL + ALT + TAB [Use the arrow keys to switch between all open apps]






· 
CTRL + ARROW + SPACEBAR [Select multiple individual items in a window or
on the desktop]






· 
CTRL + SHIFT + ARROW [Select a block of text]






· 
CTRL + ESC [Open the Start screen]






· 
CTRL + SHIFT + ESC [Open Task Manager]






· 
CTRL + SHIFT [Switch the keyboard layout when multiple keyboard layouts
are available]






· 
CTRL + SPACEBAR [Turn the Chinese input method editor (IME) on or off]






· 
SHIFT + F10 [Display the shortcut menu for the selected item]






· 
SHIFT + ARROW [Select more than one item in a window or on the desktop,
or select text within a document]






· 
SHIFT + DELETE [Delete the selected item without moving it to the
Recycle Bin first]






· 
RIGHT ARROW [Open the next menu to the right, or open a submenu]






· 
LEFT ARROW [Open the next menu to the left, or close a submenu]






·  ESC [Stop or leave
the current task]













Windows Shortcut
Keys






  • Win + F1 [Open Windows Help and support]

  • Win [Display or hide the Start screen]

  • Win + B [Set focus in the notification area]

  • Win + C [Open Charms]

  • Win + D [Display and hide the desktop]

  • Win + E [Open File Explorer]

  • Win + F [Open the Search charm and search for files]

  • Win + H [Open the Share charm]

  • Win + I [Open the Settings charm]

  • Win + K [Open the Devices charm]

  • Win + L [Lock your PC or switch people]

  • Win + M [Minimize all windows]

  • Win + O [Lock device orientation]

  • Win + P [Choose a presentation display mode]

  • Win + Q [Open the Search charm to search everywhere or
    within the open app (if the app supports app search)]

  • Win + R [Open the Run dialog box]

  • Win + S [Open the Search charm to search Windows and
    the web]

  • Win + T [Cycle through apps on the taskbar]

  • Win + U [Open Ease of Access Center]

  • Win + V [Cycle through notifications]

  • Win + SHIFT + V [Cycle through notifications in reverse
    order]

  • Win + W [Open the Search charm and search for settings]

  • Win + X [Open the Quick Link menu]

  • Win + Z [Show the commands available in the app]

  • Win + , [Temporarily peek at the desktop]

  • Win + PAUSE [Display the System Properties dialog box]

  • Win + CTRL + F [Search for PCs (if you’re on a
    network)]

  • Win + SHIFT + M [Restore minimized windows on the
    desktop]

  • Win + (NUMBER 1-9) [Open the desktop and start the app
    pinned to the taskbar in the position indicated by the number. If the app
    is already running, it switches to that app.]

  • Win + SHIFT + (NUMBER 1-9) [Open the desktop and start
    a new instance of the app pinned to the taskbar in the position indicated
    by the number]

  • Win + CTRL + (NUMBER 1-9) [Open the desktop and switch
    to the last active window of the app pinned to the taskbar in the position
    indicated by the number]

  • Win + ALT + (NUMBER 1-9) [Open the desktop and open the
    Jump List for the app pinned to the taskbar in the position indicated by
    the number]

  • Win + CTRL + SHIFT + (NUMBER 1-9) [Open the desktop and
    open a new instance of the app located at the given position on the
    taskbar as an administrator]

  • Win + TAB [Cycle through recently used apps (except
    desktop apps)]

  • Win + CTRL + TAB [Cycle through recently used apps
    (except desktop apps)]

  • Win + SHIFT + TAB [Cycle through recently used apps
    (except desktop apps) in reverse order]

  • Win + CTRL + B [Switch to the app that displayed a
    message in the notification area]

  • Win + UP ARROW [Maximize the window]

  • Win + DOWN ARROW [Remove current app from screen or
    minimize the desktop window]

  • Win + LEFT ARROW [Maximize the app or desktop window to
    the LEFT side of the screen]

  • Win + RIGHT ARROW [Maximize the app or desktop window
    to the RIGHT side of the screen]

  • Win + HOME [Minimize all but the active desktop window
    (restores all windows on second stroke)]

  • Win + SHIFT + UP ARROW [Stretch the desktop window to
    the top and bottom of the screen]

  • Win + SHIFT + DOWN ARROW [Restore/minimize active
    desktop windows vertically, maintaining width]

  • Win + SHIFT + LEFT ARROW or RIGHT ARROW [Move an app or
    window in the desktop from one monitor to another]

  • Win + SPACEBAR [Switch input language and keyboard
    layout]

  • Win + CTRL + SPACEBAR [Change to a previously selected
    input]

  • Win + ENTER [Open Narrator]

  • Win + SHIFT + . [Cycle through open apps]

  • Win + . [Cycle through open apps]

  • Win + / [Initiate IME reconversion]

  • Win + ALT + ENTER [Open Windows Media Center]

  • Win + +/- [Zoom in or out using Magnifier]

  • Win + ESC [Exit Magnifier]







File Handling Short cut keys






  • ALT + D [Select the address bar]

  • CTRL + E [Select the search box]

  • CTRL + F [Select the search box]

  • CTRL + N [Open a new window]

  • CTRL + W [Close the current window]

  • CTRL + mouse scroll wheel [Change the size and
    appearance of file and folder icons]

  • CTRL + SHIFT + E [Display all folders above the
    selected folder]

  • CTRL + SHIFT + N [Create a new folder]

  • NUM LOCK + * [Display all subfolders under the selected
    folder]

  • NUM LOCK + + [Display the contents of the selected
    folder]

  • NUM LOCK + – [Collapse the selected folder]

  • ALT + P [Display the preview pane]

  • ALT + ENTER [Open the Properties dialog box for the
    selected item]

  • ALT + RIGHT ARROW [View the next folder]

  • ALT + UP ARROW [View the folder that the folder was in]

  • ALT + LEFT ARROW [View the previous folder]

  • BACKSPACE [View the previous folder]

  • RIGHT ARROW [Display the current selection (if it’s
    collapsed), or select the first subfolder]

  • LEFT ARROW [Collapse the current selection (if it’s
    expanded), or select the folder that the folder was in]

  • END [Display the bottom of the active window]

  • HOME [Display the top of the active window]

  • F11 [Maximize or minimize the active window]














General
folder/shortcut control






  • F4: Selects the Go To A Different Folder box and
    moves down the entries in the box (if the toolbar is active in Windows
    Explorer)

  • F5: Refreshes the current window.

  • F6: Moves among panes in Windows Explorer

  • CTRL+G: Opens the Go To Folder tool (in Windows 95
    Windows Explorer only)

  • CTRL+Z: Undo the last command

  • CTRL+A: Select all the items in the current window

  • BACKSPACE: Switch to the parent folder

  • SHIFT+click+Close button: For folders, close the
    current folder plus all parent folders







Controllers in Number Pad of the
keyboard






  • Numeric Keypad *: Expands everything under the current
    selection

  • Numeric Keypad +: Expands the current selection

  • Numeric Keypad -: Collapses the current selection.

  • RIGHT ARROW: Expands the current selection if it is not
    expanded, otherwise goes to the first child

  • LEFT ARROW: Collapses the current selection if it is
    expanded, otherwise goes to the parent














Windows Screen shortcut keys






  • Win + . [Enter Rearrange mode and select apps or
    dividers across monitors]

  • Win + LEFT ARROW [Move app divider left]

  • Win + RIGHT ARROW [Move app divider right]

  • Win + UP ARROW [Maximize app]

  • Win + DOWN ARROW [Close app]

  • Win + ESC [Exit Rearrange mode]