Shared Flashcard Set

Details

Servlets html javascript
html javascript servlet
89
Computer Science
Graduate
01/02/2018

Additional Computer Science Flashcards

 


 

Cards

Term

 

 

 

 

Describe an http request.

Definition

An http client sends an http request to a server in the form of a request message.

 

Request line

request method

request uri

request header fields

Term
List the HTTP request methods
Definition

get

head

post

put

delete

connect

options

trace

Term
Describe header request fiels
Definition
the header request fields allow the client ot pass additional information about hte request and about hte client itself to the server.
Term
Give simple example of request message
Definition
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Term
What is a URI?
Definition

A uniform resource identifier is a case-sensative string containing name, location, etc to identify a resource.

 

syntax: URI = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]

 

Term
What is the http date/time stape format?
Definition
Greenwich mean time, no exceptions
Term
What is the default character set?
Definition
US-ASCII
Term
What is a content enconding?
Definition

content encoding value indicates that an encoding algorithm has been used to encode the content before passing it over to the network.

Accept-encoding: gzip

or

Accept-encoding: compress

or 

Accept-encoding: deflate
Term
What are language tags?
Definition

http uses language tags within the accept-language and content-language fields. A language tag is composed of one or more parts: a primary langauge tag and possibly empty series of subtags.

 

Term
What is an http client?
Definition
an http client is a program (web browser) that establishes a connection to a server for the purpose of sending one or more http request messages.
Term
What is an http server?
Definition
an http server is a program that accepts connections in order to serve http requests by sending http response messages.
Term
What is an http message start line
Definition

A start-line will have the following generic syntax:

start-line = Request-Line | Status-Line

We will discuss Request-Line and Status-Line while discussing HTTP Request and HTTP Response messages respectively. For now, let's see the examples of start line in case of request and response:

GET /hello.htm HTTP/1.1     (This is Request-Line sent by the client)

HTTP/1.1 200 OK             (This is Status-Line sent by the server)
Term
What are header fields
Definition

http header fields provide required information about the reuqest or response or about the object sent in the message body

 

 

Term
What are the 4 types of http message headers?
Definition
  • General-header: These header fields have general applicability for both request and response messages.

  • Request-header: These header fields have applicability only for request messages.

  • Response-header: These header fields have applicability only for response messages.

  • Entity-header: These header fields define meta information about the entity-body or, if no body is present, about the resource identified by the request.

Term
what is the message body of an http message?
Definition

A message body is the one which carries the actual HTTP request data (including form data and uploaded, etc.) and HTTP response data from the server ( including files, images, etc.). Shown below is the simple content of a message body:

<html>
   <body>
   
      <h1>Hello, World!</h1>
   
   </body>
</html>
Term
What is an http response?
Definition

After receiving and interpreting a request message, a server responds with an HTTP response message:

  • A Status-line
  • Zero or more header (General|Response|Entity) fields followed by CRLF
  • An empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields
  • Optionally a message-body
Term
what are the parts of an http response
Definition

Message status line

http version

status code

response header fields

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed
Term
What are the http methods?
Definition

get

head

post

put

delete

connect

options

trace

Term
What does the get method do?
Definition
A GET request retrieves data from a web server by specifying parameters in the URL portion of the request. This is the main method used for document retrieval. 
Term
What does the post method do?
Definition
The POST method is used when you want to send some data to the server, for example, file update, form data, etc. 
Term
What are the 5 http status codes?
Definition
S.N. Code and Description
1 1xx: Informational

It means the request has been received and the process is continuing.

2 2xx: Success

It means the action was successfully received, understood, and accepted.

3 3xx: Redirection

It means further action must be taken in order to complete the request.

4 4xx: Client Error

It means the request contains incorrect syntax or cannot be fulfilled.

5 5xx: Server Error

It means the server failed to fulfill an apparently valid request.

Term
What is url encoding?
Definition
HTTP URLs can only be sent over the Internet using the ASCII character-set, which often contain characters outside the ASCII set. So these unsafe characters must be replaced with a %followed by two hexadecimal digits.
Term
What is the difference between  URI AND URL
Definition

URIs identify and URLs locate; however, locators are also identifiers, so every URL is also a URI, but there are URIs which are not URLs.

 

uniform resource locator

uniform resource identifier

Term
What is a Servlet?
Definition

A servlet is a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP, the HyperText Transfer Protocol.

A servlet is an interface in java.

it is implemented by GenericServlet.

Defines methods that all servlets must have.

This interface defines methods to initialize a servlet, to service requests, and to remove a servlet from the server. These are known as life-cycle methods and are called in the following sequence:

  1. The servlet is constructed, then initialized with the init method.
  2. Any calls from clients to the service method are handled.
  3. The servlet is taken out of service, then destroyed with the destroy method, then garbage collected and finalized.
Term

what is the genericservlet class?

 

Definition

Defines a generic, protocol-independent servlet. To write an HTTP servlet for use on the Web, extend HttpServlet instead.

GenericServlet implements the Servlet and ServletConfig interfaces. GenericServlet may be directly extended by a servlet, although it's more common to extend a protocol-specific subclass such as HttpServlet.

GenericServlet makes writing servlets easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface. GenericServlet also implements the log method, declared in the ServletContext interface.

Term
What is the httpservlet class?
Definition
public abstract class HttpServlet
extends GenericServlet
implements java.io.Serializable

Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these:

  • doGet, if the servlet supports HTTP GET requests
  • doPost, for HTTP POST requests
  • doPut, for HTTP PUT requests
  • doDelete, for HTTP DELETE requests
  • init and destroy, to manage resources that are held for the life of the servlet
  • getServletInfo, which the servlet uses to provide information about itself

There's almost no reason to override the service method. service handles standard HTTP requests by dispatching them to the handler methods for each HTTP request type (the doXXX methods listed above).

Likewise, there's almost no reason to override the doOptions and doTrace methods.

Term
What is the inheritance tree of a servlet?
Definition

Servlet interface

GenericServlet

HttpServlet (abstract)

MyServlet (implements abstract methods)

Term
Why are there no constructors in servlets?
Definition
A servlet is just like an applet in the respect that it has an init() method that acts as a constrcutor. Since the servlet environment takes care of instantiating the servlet, an explicit constructor is not needed. Any initialization code you need to run should be placed in the init() method since it gets called when the servlet is first loaded by the servlet container.
Term

What is the difference between GenericServlet and HttpServlet?

Definition

GenericServlet is a class.

HttpServlet is an abstract class.

HTTPServlet is for http responses.

Generic Servlet would be used for FTP and other protocols.

Term

What is the difference between the doGet and doPost methods?

Definition

doGet is called in response to an HTTP GET request. This happens when users click on a link, or enter a URL into the browser’s address bar. It also happens with some HTML FORMs (those with METHOD=”GET” specified in the FORM tag).

doPost is called in response to an HTTP POST request. This happens with some HTML FORMs (those with METHOD=”POST” specified in the FORM tag).

Both methods are called by the default (superclass) implementation of service in the HttpServlet base class. You should override one or both to perform your servlet’s actions. You probably shouldn’t override service().

Term

What is meant by the term “business logic”?

Definition
More precisely, in a three-tier architecture, business logic is any code that is not specifically related to storing and retrieving data (that’s “data storage code”), or to formatting data for display to the user (that’s “presentation logic”). 
Term

 How can I explicitly unload a servlet or call the destroy method?

Definition
You can't.
Term

What is a web application (or “webapp”)?

Definition
A web application is a collection of servlets, html pages, classes, and other resources that can be bundled and run on multiple containers from multiple vendors. A web application is rooted at a specific path within a web server. 
Term

What is a Servlet Context?

Definition
A Servlet Context is a grouping under which related servlets (and JSPs and other web resources) run. They can share data, URL namespace, and other resources. There can be multiple contexts in a single servlet container.
Term

What are the different cases for using sendRedirect() vs. getRequestDispatcher()?

Definition
When you want to preserve the current request/response objects and transfer them to another resource WITHIN the context, you must use getRequestDispatcher or getNamedDispatcher.
Term
What is the lifecyle of a servlet?
Definition

init()--used as a constructor

service() --where we override doGet

destroy() no control.

Term
DEscribe servlet mapping
Definition

Servlet mapping occurs in the web.xml file and as an annotation.

in the xml file, there are 4 or 5 lines.

<servlet-name>

<servlet-class>

<load on startup> optional

<servlet-mapping>

<servlet-name>

<url-pattern>

Term
what is javascript?
Definition

JavaScript, often abbreviated as JS, is a high-level, dynamic, weakly typed, prototype-based, multi-paradigm, and interpreted programming language. Alongside HTML and CSS, JavaScript is one of the three core technologies of World Wide Web content production.

 

it is used to manipulate the DOM.

Term
What is AJAX?
Definition

ajax stands for asynchronous javascript and xml.

it means it's non-blocking

 

 

Term
What are the components of an ajax request?
Definition
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
    var DONE = this.DONE || 4;
    if (this.readyState === DONE){
        alert(this.readyState);
    }
};
request.open('GET', 'somepage.xml', true);
//request type, url, aynchronous is true request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
Term
What is the DOM?
Definition

Document object model.

The Document Object Model (DOM) is a cross-platform and language-independent application programming interface that treats a HTMLXHTML, or XML document as a tree structure wherein each node is an object representing a part of the document. The objects can be manipulated programmatically and any visible changes occurring as a result may then be reflected in the display of the document.The Document Object Model (DOM) is a cross-platform and language-independent application programming interface that treats a HTMLXHTML, or XML document as a tree structure wherein each node is an object representing a part of the document. The objects can be manipulated programmatically and any visible changes occurring as a result may then be reflected in the display of the document.

Term

What is JSON?

 

Definition

javascript object notation

common format

human readable

key value pairs

Term
What is meta-data?
Definition

data about data.

pom.xml

web.xml

Term
What si the difference between form and javascript?
Definition

form is synchronous

javascript is asynchronous.

Term
What is maven?
Definition

Maven is a project management and comprehension tool.

 

Maven provides developers a complete build lifecycle framework. Development team can automate the project's build infrastructure in almost no time as Maven uses a standard directory layout and a default build lifecycle.

Term
what is the POM?
Definition

POM stands for project oject model.

it is the fundamental unit of work in maven.

it's an xml file.

contains information to build the file along with configuratoin details.

Term
What are the elements of a project's coordinates?
Definition

<groupId>

<artifactId>

<version>

Term
What are the different maven build lifecycles?
Definition
default, clean site
Term
What are the phases of the default lifecycle?
Definition
validate, compile, test, package, integration-test, verify, install,deploy
Term
what would the command mvn clean do?
Definition
this command removes the target directory with all the build data before starting the build process.
Term
What is a goal?
Definition
a goal represents a specific task which contributes to hte building and managing of a project.
Term
What is an archetype?
Definition
archtype is a maven pligin whose task is to create a project structure as per its template
Term
what is a dependency?
Definition

a dependency is an artifact that maven will include as part of hte build.

it's like including a jar file in your classpath

Term

What is a maven repository?

what are the local and central repositories?

Definition

a maven repository is a directory where all the project jars, libraries, plugins or any other project artifacts are stored and can be easily used by maven.

maven has a local repository and a remote.

 

Term
What is the default location of your local repository?
Definition
.m2/repository
Term
how do you deploy a web applicatoin using maven?
Definition

using the appropriate maven plugin such as weblogic-maven-plug or tomcat-maven - plugin

the plugin info must be included in the pom file

then exceute the goal assicated with the maven plugin.

mvn weblogic:deploy

Term
What is a snapshot?
Definition

snapshot is a special version that indicates a current development copy.

unlike regular version, maven checks for a new snapshot version in a remote repository for every build.

Term
how do you install a jar file to your local repository?
Definition
mvn install: install-file -dfile = path -dgroupid=com.example -datrifactid = artifact -dversion =1.0.0 -dpacking=jar
Term
what is hte command to create a new project based on an archtype?
Definition
mvn archetype:generate -dgroupid=yourproject's group id -dartifactid=yourprojects' artifact id -darchetypeartifactid = maven-archtye-archetype
Term
in what order does maven resolve dependencies?
Definition

search for dependencies in local .m2

sarch for dependencies in central repository

if remote repo

search for depencies in remote repo

if no remote repo

stop processing and error

 

Term
what is connection pool?
Definition
a connection pool contains a group of jdbc connection that are created when the connection pool is registered.
Term
what is a cursor?
Definition

oracle creates a memmory area known as context area for processing a sql statement.

 

a cursor is a pointer to this context area.

Term
what is an impllicit cursor?
Definition
implicit cursors are automatically created by oracle whenever an sql statement is executed, when there is no explcicit cursor fot he statemnt
Term
what is an explicit cursor?
Definition
explciity cursors are programmer defined cursors for gaining more control over the context area
Term
what is a cursor?
Definition

oracle creates a memmory area known as context area for processing a sql statement.

 

a cursor is a pointer to this context area.

Term
What is an implicit cursor?
Definition
implicit cursors are automatically created by oracle whenever a sql statement is executed when there is no explicit cursor for the statement.
Term
what is an explicit cursor?
Definition
explicit cursors are programmer defined cursors for gaining more control over the context area.
Term
what is amazon ec2 service?
Definition

ec2 use xen virtualization

it allows you to launch virtual machines that scale accroding to your needs

Term
what is the relation between ec2 instance and ami?
Definition
we can launch different types of instances from a single AMI.
Term
what is amazon machine image?
Definition
an amazon machine image is a template that contains a software configuration (OS).from ami we can launch an instance, which is a copy of the ami running as a virtual server
Term
explain storage for amazon ec2 instance
Definition

amazon provides many data storage options for your isntances.

each option has a unique combination of performance and durability.

these storage options can be used independently or in combination to suit your requirements

 

there are 4 types

Amazon EBS

Amazon EC2 intance store

Amazon S3

Adding storage

Term
What is EBS
Definition

Elastic block store is a durable, block-level storage volume that you can attach to a running amazon ec2 instance. the EBS persists independently from the EC2.

after attached to an ec2 it can be used like a physical hdd.

Term
what is amazon ec2 instance store?
Definition
storage disk that is attached to the host computer is referreed to as an instance store. instances storage provides temporary blcock-level storage for amazon ec2 instances.
Term
what is route 53?
Definition
amazon route 53 is a highly available and scalable cloud domain name seystem web service
Term
what is amazon elastic load balancing?
Definition
Elastic load balancing automatically distrubtes incoming app traffic across multiple amazon ec2 instances in the cloud.
Term
what are regions and availability zones?
Definition

the aws cloud infrastructure is built around regions and availability zones.

A region is a physical location  which has multiple availability zones.

Availability zones consists of one ore more discrete data centers

Term
what is a key pair?explain how to create a key pair.
Definition

EC2 uses pulbic key cryptography to encrypt and ecrypt login information. public key cryptography uses a pulbic key to encrypt a piece of data such as a password and then the recipeiint uses the private key to decrypt the data. these keys are the key pair.

to login to an ec2 you must create a key pair. 

windows: key pair to get admin password.

linux: uses key pair to login using ssh

Term
what is a security group in amazon ec2? what are the features of security group in amazon ec2?
Definition
a security group acts as a virtual firewall that controls the traffic for one or more instances.
Term
how to connect to your amazon ec2 instance?
Definition

you connect to a linux ec2 using ssh or putty.

you connect to windows using remote desktop

Term
how are you charged in amazon ec2?
Definition
aws allows you to pay for servces on demand and to use as much or as little at any given time as you need.
Term
can i vertically scan an ec2 instance?
Definition
yes. you can start a new larger instance than what you started with . pause, detach ebs stop live isntance. detach its root volume, attach new root volume to server and then start again.
Term
What is auto-scaling how does it work?
Definition
autoscaling is a feature of aws which allows you to configure and automatically provision and spinup new instances without the need for your intervention. you configure a threshold to launch a new isntance.
Term
what automation tools cna i use to spinup servers?
Definition

the most obvious way to is to roll your own scripts and use the aws api tools.

script->use config management and provision tool.

Term
what is configuration management and why would i want to use it with cloud provisioning of resources?
Definition

configuration management brings a large automation tool into the picture managing servers like strings of a puppet.

this forces tandarization, best practices and reproducibility as all configs are versioned and managed.

Term
what is the difference between scalability and elasticity?
Definition

scalability is a characteristic of cloud ocmputing through which increasing workload can be handled by increasing in proportion and the amount of resource capacity

elasticity is being one of hte characteristics provides the concept of commisioning and decommisioning of large amount of resource capacity dynamically. it is measured by the speed by which resources are coming on demand and the usage of those resources.

Term
what are the different layers of cloud computing?
Definition

infrastructure as a service (hardware)

platform a sa service (cloud app platform for devs)

software as a service (privdes cloud apps which are use directly)

Term
how do you use amazon sqs?
Definition
amazon simple queue service is a fast reliable managed message queing services.
Term
how buffer is used in AWS?
Definition
buffer is ued to make the system more resilient to burst ortraffic or load by synchronizing different components .
Term
what are security best practices for EC2?
Definition

restric acess by only allowing trusted hosts or networks.

review the rules in your security group regularly.

only open up permissions you require.

disable password based logins for isntances launched from ami.

Supporting users have an ad free experience!