HTLM, CSS, XML, BootStrap, Servlets, Log4J (Week 3)

Ace your homework & exams now with Quizwiz!

Different status codes from servers

*1xx series* - informative 1) 100 - Continue-request means request partially accepted, continue sending the rest. *2xx series* - success 1) 200 - OK means request successful, response received 2) 201 - Created, resource created on server 3) 202 - Request accepted, please wait for response *3xx series* - Redirection 1) 301 - Page moved permanently, url no longer points to a valid page 2) 302 - Page moved temporarily *4xx - Client Error* 1) 400 - Bad request, your request isn't parsable 2) 401 - Unauthorized incorrect username/password 3) 403 - Forbidden, you do not have the correct role to view it 4) 404 - Not Found, no such page *5xx - Server Error* 1) 500 - Internal Server error, and exception was thrown 2) 503 - Overloading Server, server can respond

What is a DTD?

*DTD - Document Type Definition* 1) A file that details the skeleton of an xml file. 2) An XML file can either write a DTO (data transfer object) in files or import on external DTD. 3) Enforces naming conventions & specific family hierarchies. 4) Uses own syntax in DTD file.

What is a DOM?

*Document Object Model (DOM)* Interface for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

What is XML? What is it used for?

*Extensible Markup Language* - Used for distributing data for use or configuration. - HTML displays data, XML stores data.

What is logging?

*Logging* -A file detailing steps and actions that took place during the apps execution. -Used to ID issues outside of the IDE console since a user typically can't see it.

What is the servlet inheritance tree?

*Look at image*

RequestDispather vs SendRedirect

*RequestDispatcher* - Provided by the request - Address of new location is hidden - Maintains request and response data, all done within the same request life-cycle. - All redirection is handled on the server by the web container. - Faster - Cannot redirect outside of it's server *SendRedirect* - Provided by the response - Address of new location is shown - A completely new request is made to the new location empty of all input - Slower

What is a XSD?

*XSD - XML Schema Definition File* 1) Works the same as DTD 2) Has more power than the DTD by enforcing datatypes. 3) You can manipulate the DOM

What are the different "sizes" for Bootstrap's grid system?

*xs* - for phones - screens less than 768px wide. (Defaults when no size is specified in the newer updates) *sm* - for tablets -screens equal to or greater than 768px wide. *md* for small laptops - screens equal to or greater than 992px wide. *lg* - for laptops and desktops - screens equal to or greater than 1200px wide.

Different ways to handle sessions

- URL Rewriting - Hidden Fields - Cookies - JSession

What is servlet?

-A servlet is a Java class that intersects requests and responses from a client and performs necessary business logic with them. -A servlet works server side -Is capable of handling complex requests obtained from a web server

What is the grid system in Bootstrap?

Bootstrap's grid system uses a series of containers, rows, and columns to layout and align content easier. (max is 12 columns)

What is CSS?

Cascading Style Sheets

What is a deployment descriptor?

The web.xml file that provides direction for requests. examples: Providing mapping for servlets and describing deployment settings for an app.

How do I get form data with servlets?

Using cookies

What is the main key feature in Bootstrap that Ryan discussed in class?

Using what is know as the "Grid System"

What are the 3 components of Log4J?

*Logger* - The tool that makes a log message at a given point in the application *Appender* - Determines where the info will be written (to console, to file, to html etc...) *Layout* - Determines what kind of info is logged and how it is ordered.

What is PrintWriter?

- A class that gives Print formatted representations of objects to a text-output stream - Used to print HTML code through the servlet to the HTML file

Absolute Vs Relative Path

a[@id="bob"] -> relative xpath (Not full root path just what is needed) bs/b[1]/a[@id="bob"] -> xpath (Full Root Path)

What would an external CSS stylesheet look like? What kind of attributes would be in it?

body { background-color:#AA44FF; color:#33AA00; } #thisGuy { font-size:72px; color:white; } .rsection { background: darkgrey; color:aliceblue; border-radius:15px; border: 5px outset #BB1919; margin: 10px; padding: 10px; }

What is the difference between a servlet config and servlet context?

*Servlet Config* - Parameters are specified for a particular servlet and are unknown to other servlets. - It is used for initializing purpose - Each servlet gets their own config. *Servlet Context* - Parameters are specified for an entire application outside of any particular servlet and are available to all the servlets within that application. - It has its application scoped and thus globally accessible across the pages.

URI vs URL

*URI:* - Uniform Resource Identifier - URIs are identifiers, and that can mean name, location, or both. *URL:* - Uniform Resource Location - The part that makes something a URL is the combination of the name and an access method, such as https://, or mailto:.

What is a front controller?

- A design pattern that aims to create a servlet which acts as the first point of contact for all requests. - It aims to delegate them to their proper end point, but must be the first servlet to determine where they go.

What is a Filter Servlet?

- A servlet that serves to intercept requests and responses before they reach their goal servlet that they were intended to begin with. - A filter is typically used to authenticate credentials or session, or provide a logging opportunity.

What is a session?

- A session is a java object that is temporary, interactive information interchange between two or more communicating devices - May store data that you want access to across requests. - Each user that visits your website should have a unique session. - You can use sessions to store and access user data as they browse your application.

What is a singleton?

- A singleton class is a design pattern that only allows a single instantiated instance of a class. - You do this by making the constructor private and having a static method of ""getInstance"" that will be a pointer to a local copy. - NOTE, in general it's NOT thread safe"

Using cookies

- A text document with key-value pairs stored on the client side that the server will accept in order to track data. - More secured and easier to track the hidden fields and url re-writing. - BUT isn't the most secure method due to the fact that cookies are stored on the client side and can be edited by them. *Only way to delete a cookie is to set its maxAge = 0*

Hidden Fields How are they used?

- Hidden value type that is never displayed to the average user. - The average user cannot change the value of the field, or interact with it. - When the user submits the form, all of the data they have entered is sent, including the data stored invisibly in the hidden fields. - It can have value that represents the session ID for tracking purposes - These require that the ID be maintained which have the same problems as URL rewriting.

What is a doctype declaration?

- It is the !DOCTYPE header. - This allows the browser to view this as an HTML page and which version of html to use. *<!DOCTYPE html>

Using JSessions

- Most secure way to deal with sessions. - They are provided by Servlet APIs - Store both a cookie on the client side and on the server side. - Requires both sides to match, if they match the session is retained for the user.

What is URL rewriting?

- Re-appending to the URL when moved to a new page - Requires developer to generate a unique ID per user. - Hard to maintain ID throughout pages since HTTP is stateless - Stateless means no information is retained b/t separate requests.

What is servlet config?

- ServletConfig object is created by web container for each servlet to pass information to a servlet during initialization. - This object is used to get configuration information from web.xml (aka Deployment Descriptor) file.

What are some things to know about GET HTTP method?

- Stores all data in the URL - Exposes passwords - Limits data to max size of URL - Use when requesting data - Do NOT use for logging in

What are somethings to know about POST HTTP method?

- Stores data in the body of a request - Unlimited space for data

What is servlet context?

- The servlet context is an interface which helps to communicate with other servlets. - It contains information to communicate to the Web application and container.

What are the servlet XML tags to know?

-1) prologue 0) webapp 1) *Display Name* - Purely descriptive 1.5) context-param 2) *Welcome-file-list* - serves to house all the of the files that your web app will search for as the landing page (homepage). They do not need to be reached specifically by name. They will be what is searched for in the event you go to website.com which doesn't specify a specific file. 3) *Welcome-file* is the index.html file Servlet tag houses the details about a specific servlet 4) *Servlet-name* is very important as it serves as the link b/t sibling tags in this document 5) *Servlet-class* Location of the physical class for the servlet 6) *Servlet-mapping* takes a <servlet> and provides details of the uri/url for intercepting the request *Servlet-name will then link the mapping to an above <servlet>*

What are the requirements to make an XML file "Well Formed"?

-XML follows the structure as HTML elements and attributes -attributes in XML are used as metadata -must have one and only one root element -all elements must have a closing tag ; tags must match case -must use entity references on reserved keywords -Attributes must be quoted, no improperly nested tags -starts with a prologue. (optional)

What is the life cycle of a servlet? (detailed overview)

1) A client sends an HTTP request to a server (ryan.com/bobbert) 2) Server takes the request, creates an empty HTTP response, flat file (not extensions). Then sends both of them to the web container. 3) Web Container checks the deployment descriptor to determine if any servlets should receive the request. 4) Web Container wraps the requests and response into their java object counter parts, then sends them to the servlet. 4a) Web Container calls init( ) if the servlet is NOT instantiated 4b) Web Container sends requests and response to service( ) in its thread and receives altered response 4c) Destroy called on web container upon server shutdown (or timeout) 5) Finished response and request received by the web container. 6) Passes unwrapped results to server 7) Server passes back to client or user

What is the life cycle of a servlet? (quick overview)

1) A server loads and initializes the servlet by init () method. 2) The servlet handles zero or more client's requests through service() method. 3) The server removes the servlet through destroy() method.

What are the log severity levels?

1) All 2) Trace - typically used before every possible method on path in code 3) Debug - typically used before every method 4) Info - precedes key actions in the app 5) Warn - precedes actions that behave in an incorrect manner that may break app 6) Error - precedes actions that have crashed the app or sets the stage fo an imminent crash 7) Fatal -precedes actions that lead to an unrecoverable crash 8) None

What are the 3 ways to integrate CSS?

1) Inline -write css directly inline using "style" 2) Internal stylesheet - By using <style> element 3) External stylesheet - Where you import a css file via the <link> tag

What is HTML used for and what should I know about it?

1) Its a markup language 2) It uses Logs 3) Interpreted by most browser 4) Used for displaying to a page 5) Tags represent an element 6) Attributes are used to customize an element Tags aren not shown to the user. (HTML Format looks like this) <h1 Attributes="">inner HTML element /element>

What is CSS used for?

1) Used to stylize your webpages making them more appealing visually to the user.

How do I perform error handling with the deployment descriptor?

<!-- in web.xml --> <error-page> <error-code>404</error-code> <location>/pepsi.html</location> </error-page>

What are some examples of the "tags" used in HTML?

<!DOCTYPE html> -Tell the the browser that this is a HTML Doc <html> -Beginning of EVERY HTML code <head> -Includes data like: title, browser and character support. <a href="document location"></a> <title> - Displays title on the site which will appear on the tab of the browser </title> </head> <body> - Where display data goes <h1>(Header 1)</h1> <p>(Paragraph)</p> <strong>(Bold Text)</strong> <span>Will display inline next to the b tag</span> </body> </html>

How do I set init params for servlet context?

<context-param> <param-name>GlobalPass</param-name> <param-value>GlobalBobbert</param-value> </context-param>

How do I create a various form data?

<form> (First name) <input type="text"name="firstname"> (Last name) <input type="text"name="lastname"> </form> *Some other input types that can be used are "radio" and "submit"*

How do I set init params for servlet config?

<init-param> <param-name>DBPass</param-name> <param-value>DBBobbert</param-value> </init-param>

How do I preload a servlet?

<load-on-startup>1</load-on-startup> <!-- in web.xml -->

How do I create an unordered/ordered list? (Example)

<ol> (Ordered list) <li>Coffee</li> (List items) <li>Tea</li> <li>Milk</li> </ol> *If you want unordered then just use <ul> instead*

How do I create a table?(Example)

<table style="width:100%"> <tr> (table row) <th>Firstname</th> (Headers) <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Jill</td> (data)) <td>Smith</td> <td>50</td> </tr> </table> *This will create table with 2 rows 1 title row and 1 items row*

What are cookies?

A cookie is simply a text document with key value pairs stored on the client side that the server will accept in order to track data from the specific computer. It's more secure than hidden files and URL rewriting and easier to set up and track. However, it is not the MOST secure way due to the fact that cookies are stored client side and can be edited client side as well.

What is Bootstrap?

A javascript/CSS library that aims to make formatting web apps much easier. One key feature of bootstrap is the grid system

What is an XML namespace?

A namespace is a collection of names. Usually specified at the top of the XSD next to Schema that helps prevent ambiguity in XML documents by allowing us to apply prefixes to them.

What are the HTTP methods?

GET POST PUT DELETE HEAD TRACE OPTIONS PATCH

What is HTML?

Hypertext Markup Language

Well formed vs valid xml

If XML meets the requirements of well formed AND conforms to an applied DTD/XSD perfectly then it is considered to be VALID

What is log4j?

Log4J is a logging infrastructure that helps collect information about the executions that were run.

Is HTML code compiled?

Nope! HTML is not compiled, it is read "as is"

What is XPath?

XPath is a path language for selecting elements within an XML document.


Related study sets

Delmar's Textbook of Electricity, Section 1, Units 1 - 5

View Set

Music Appreciation - Types of Listeners

View Set

neuroscience 10 module 6-8 quizzes

View Set

HST 120: Chapter 4 - The Northern Colonies in the Seventeenth Century, 1601-1700

View Set

ENTREPRENEURSHIP AND SMALL BUSINESS MANAGEMENT EXAM

View Set