Shared Flashcard Set

Details

OCEWCD Chapter 4
Slides for Basham, Sierra & Bates Head First Servlets & JSP, Chapter 4
6
Computer Science
Professional
07/26/2012

Additional Computer Science Flashcards

 


 

Cards

Term

Fill in the blanks:

public void doGet(HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

response.setContentType(someMimeType);

byte[] data = goGetSomeDataSomeplace();

__________________ out =

response.get__________________ ();

out.write(data);

out.flush();

out.close();

}

Definition

ServletOutputStream out =

response.getOutputStream();

(page 129)

Term

Fill in the blanks:

public void doGet(HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

response.setContentType("text/plain");

String text = goGetSomeTextSomeplace();

__________________ out =

response.get__________________ ();

out.println(text);

}

Definition

PrintWriter out = response.getWriter();

(page 132)

Term

Both the setHeader(String,String) and addHeader(String,String) methods of the HttpServletResponse interface will add the specifed header name and value to the response if it does not already exist.

 

What does each method do if the header does already exist?

Definition
  • setHeader(String,String) will overwrite the header's current value with the new value.
  • addHeader(String,String) will add the new value to the header's list of values.

(page 133)

Note: The getHeaders() method returns Collection<String>.

Term

Can a postRequest be bookmarked?

How do we know when to use a post request?

Definition

No only Get requests can be bookmarked

use a post request when you want to update or change something on the server. pg.111

Term

Is Post indempotent?

Is Get indempotent?

What bad thing can happen is a Post is used twice?

 

Definition

Get is indempotent

Post is not indempotent

If we post something to the server more than one a second transaction can occure

pg 116

Term
Can you implement a non indempotent doGet()?
Definition

Yes, there is nothing fromm stopping you from implementing a non indempotent doGet(), although this is against the servlet spec.

pg116

Supporting users have an ad free experience!