• No results found

Usability. Usability

N/A
N/A
Protected

Academic year: 2021

Share "Usability. Usability"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 11

Objectives

Objectives

Review Usability

Web Application Characteristics

Review Servlets

Deployment

Sessions, Cookies

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 22

Usability

Usability

Trunk Test

Harder than you probably thought Your answers didn’t always agree Important because of search engines

Amazon

Local navigation

IMDb

Only one with breadcrumb but least necessary?

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 33

Usability

Usability

Time

Sectioning

Local Navigation is down the page “below the fold”

Encyclopedia Britannica

Table of Contents

Lessons:

Popular sites aren’t necessarily the most usable? Hmm…

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 44

Discussion of

Discussion of

Quality Attributes

Quality Attributes

More to usability than navigation

How easy to do the functionality

What are some of the differences between traditional applications and web applications?

Leads to differences in quality attributes

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 55

Comparison of Applications

Comparison of Applications

Frequent (~days), inexpensive Infrequent (~monthly), expensive Releases

Returning customers; later but better

Time to market Economics

Traditional languages and Scripting languages, HTML, Other languages Java, C, C++, etc. Languages Programmers, graphics designers, usability engineers, Network, DB Programmers Development Team Network, DB Technologies

Client, Server (& more) On clients Location Web Applications Traditional Attribute May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 66

Quality Attributes

Quality Attributes

Later but better is okay Time-to-market

Short maintenance cycle, frequent updates Maintainability

Thousands of requests per second, more? Scalability

24/7/365 Availability

Must work, or go to another site Reliability

Protect user data, information Security

Must be usable, or go to another site Usability

Web Applications Attribute

(2)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 77

How Have Web Sites Changed to

How Have Web Sites Changed to

Meet Quality Demands?

Meet Quality Demands?

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 88

How Have Web Sites Changed to

How Have Web Sites Changed to

Meet Quality Demands?

Meet Quality Demands?

Additional tiers

Add security, robustness

Additional servers, databases

Running in parallel Add availability

New technologies

Better programming languages for writing, maintaining code

Separating presentation from business logic

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 99

Discussion

Discussion

Paper was written in 2002: Did anything seem dated?

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1010

Servlets

Servlets

Review

Review

What application do we need to execute Servlets?

What class do all Servlets extend?

What methods do Servlets need to override to handle GET and POST requests?

How do Servlets send an HTML document/response to the client?

How do Servlets get data from the client?

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1111

The Example Servlet Flow

The Example Servlet Flow

Server Web Application Server Client HTTP Request, data Response HTML Form HTML Document Web Browser subm it doGet doGet () () May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1212

Lab

Lab

4: Modify

4: Modify

SurveyServlet

SurveyServlet

Currently: Inefficient implementation

In init

Automatically called by server on start up Open file, read/initialize votes

In destroy

Automatically called by server Write file

(3)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1313

Web App Directory Structure

Web App Directory Structure

projectname/

XHTML, CSS, and JSP files

projectname/WEB-INF

Other resources, e.g., web.xml

projectname/WEB-INF/classes

Servlet and utility (data structures, etc) Why we put our Servlets in servlets package

projectname/WEB-INF/lib

Jar files that application depends on

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1414

web.xml

web.xml

File

File

Describes how to deploy the web application

XML file

Used for data

Marked up with elements

Same rules as XHTML: close most recently opened tag, attributes in quotes

DTD: Document Type Definition

Define elements that can be in a particular XML document

Includes specification of attributes, nesting

<tag attr=“value”> Content </tag>

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1515

web.xml

web.xml

File

File

Top-level: <webapp>

<servlet> element describes a servlet

<servlet-mapping> elements maps URLs to Servlets

May want to have shorthands, aliases Restrict users’ direct access to servlets

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1616

web.xml

web.xml

File

File

Subelements of <servlet>

optional parameter containing a name-value pair that is passed to the servlet on initialization. Contains elements, <param-name> and <param-value>, which contain the name and value, respectively, to be passed to the servlet.

<init-param>

fully qualified class name of the servlet

<servlet-class>

canonical name of the deployed servlet

<servlet-name>

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1717

Lab 4: Configure

Lab 4: Configure

SurveyServlet

SurveyServlet

Configure SurveyServlet to use a given file

Add the following to web.xml file: <init-param>

<param-name>surveyfile</paramname> <param-value>survey.results</param-value> </init-param>

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1818

Modify

Modify

init

init

Method

Method

Use ServletConfig’s getInitParameter method // calls HttpServlet method

filename = getInitParameter(”surveyfile"); // open file …

(4)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 1919

Deployment: WAR files

Deployment: WAR files

Web Archives

Analog to JAR files

Copy into webapps directory of web application server

Server will automatically extract files and run Procedure for Apache/Tomcat and Resin

Can export WAR files from Eclipse

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2020

Maintaining State

Maintaining State

If you have multiple pages, how can you save or accumulate data?

Example scenario: buying a book

Login

Form WhichBook CreditCard Verify

Server Server Server Server

D1 D1 D1, D2 D1, D2 D1, D2, D3

D1, D2,

D3 D1, D2,D3, D4

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2121

Maintaining State

Maintaining State

If you have multiple pages, how can you save or accumulate data?

Hidden fields (type=hidden) Cookies

Sessions

Login

Form WhichBook CreditCard Verify

Server Server Server Server

D1 D1 D1, D2 D1, D2 D1, D2, D3

D1, D2,

D3 D1, D2,D3, D4

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2222

Hidden Fields

Hidden Fields

Data is coming from client

Users can see the hidden fields

View HTML Source

Users can change the data

Useful in limited situations

<input type=“hidden” name=“userid” value=“superfly”/>

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2323

Cookies

Cookies

• A popular way to customize web pages is to use cookies

• Cookies are sent from the webapp to the client • Part of an HTTP header in the response to a client

Every HTTP transaction includes HTTP headers Not part of the HTML content

• Store information on the client’s computer • Client includes cookies in HTTP headers in

subsequent requests

Provides way to do behavior tracking

• Do you see any problems with cookies?

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2424

Process with Cookies

Process with Cookies

Client Web App

Server Web Browser

• Cookies

Associated with server name Part of HTTP Headers

• Example: Amazon.com

Cookie stores your name, login information Example: Not Sara?

HTTP Request, Cookies Response: Cookies, HTML Document Cookies

(5)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2525

Cookies in Java

Cookies in Java

Cookies have a name and value

Create a Cookie object using its constructor

Part of javax.servlet.http.Cookie

Example: store a user’s preferred language on the client

App only has to ask for this information once

String cookie_name = new String(“pref_language”); String cookie_value = new String(“English”);

Cookie new_cookie = new Cookie(cookie_name, cookie_value);

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2626

Sending the Cookie to the Client

Sending the Cookie to the Client

• HTTP header is sent first

• Cookie(s) must be added to the response object before you start writing to the client

• Call addCookie() on HttpServletResponse object before you call the getWriter() method • Inside of doGet or doPost method:

Cookie c = new Cookie( “pref_language”, “English” ); c.setMaxAge(60*60*24*365); // max age of cookie response.addCookie(c);

. . .

output = response.getWriter();

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2727

The

The

HttpServletResponse

HttpServletResponse

Object

Object

void addCookie(Cookie)

Add a Cookie to the header in the response to the client

The cookie will be stored on the client,

depending on the max-life and if the client allows cookies

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2828

Cookies: Maximum Ages

Cookies: Maximum Ages

The maximum age of the cookie is how long the cookie can live on the client (in seconds)

When a cookie reaches its maximum age, client deletes it

-1 means persists until browser shuts down c.setMaxAge(60*60*24*365); // max age of cookie

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 2929

Retrieving Cookies

Retrieving Cookies

• Call getCookies() on HttpServletRequest object

Returns an array of Cookie objects

Represents all cookies that server previously sent to the client

• For example, inside of doPost

Cookie[] cookies = request.getCookies();

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3030

Voiding Cookies

Voiding Cookies

May want to delete cookies when user logs out

Especially for sensitive information

// void cookie and send back to the user userid_cookie.setMaxAge(0);

(6)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3131

Session

Session

One user’s visit to an application

Can be made up of many requests

Server maintains session with particular client

Can maintain state within that session

Server has a timeout

If no requests from client for specified period of time (the timeout), user’s session ends

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3232

Session variables

Session variables

HttpSession object can store data for session

Simpler for developer Reduce network traffic Known as session attributes

• Have names and values

• Store, access, and remove attributes:

Like a HashMap

void setAttribute(String name, Object value)

• Values no longer need to be strings

• Cookies and Parameters had to be strings Object getAttribute(String name)

void removeAttribute(String name)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3333

Example Session Variables

Example Session Variables

• User gives application data

• Application stores data in session variable session.setAttribute("username", username); • Application can use later in session, without user

having to give information every time String username =

session.getAttribute(“username”); • More examples:

Server computes information once, caches in session Shopping carts

name

value

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3434

Getting a Session

Getting a Session

HttpServletRequest’s

getSession(boolean) method

Returns the current HttpSession object Boolean parameter specifies if a new session

should be created if one does not already exist

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3535

Other Useful Session Methods

Other Useful Session Methods

•setMaxInactiveInterval(), getCreationTime(),

getLastAccessedTime()

If want shorter than server’s timeout

•invalidate()

Invalidates session, unbinds objects bound to it

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3636

Lab 4: Add

Lab 4: Add

Session Variable

Session Variable

LoginServlet will add a session variable with name “authenticated”

(7)

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3737

ServletContext

ServletContext

Share state among multiple clients

Allow multiple users to interact in, e.g., chat rooms, online meeting, reservation systems

Info about servlet’s environment

E.g., server’s name

log(): method to write to a log file

Context attributes

getAttribute, setAttribute, removeAttribute

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3838

Eclipse Development Hints

Eclipse Development Hints

Eclipse: allocated more memory

Safe bet: restart server whenever change to a servlet or web.xml file

Typical programming

Write a few lines of code/make small changes Run, test

Repeat

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 3939

Project Discussion

Project Discussion

May 2, 2008

May 2, 2008 Sprenkle - CS297Sprenkle - CS297 4040

TODO

TODO

Lab 4: More Servlets

Design Documents, Work Plan

References

Related documents

◆ Guidelines for planning, implementing, and reviewing a comprehensive maintenance training program ◆ Easy-to-use techniques for improving your “Maintenance IQ” and your value to

Many activities are shown in the alphabetized list below, with calories expended per hour for four different weights: 130 lbs, 155 lbs, 180, lbs, 205 lbs. Keep in mind that

The two main functions of natural ventilation are: (i) provision of good indoor air quality without any electricity demand for moving the air, and (ii)

It is obvious that nickel nitrate is shown by the discoloration around the bright particles in Figure 29(a) and (c) effectively coats the LSGM particles. LSGM is not

EagleView’s complaint touted the close competition between Respondents, alleging, “Xactware has developed a product, known as Aerial Sketch, which enables it to compete directly with

[r]

(Research &amp; Policy Brief). Portland, ME: University of Southern Maine, Muskie School of Public Service, Maine Rural Health Research Center.. areas), and are more likely to

P ETLAMUL W., P RASERTSAN P., 2012 – Evaluation of strains of Metarhizium anisopliae and Beauveria bassiana against Spodoptera litura on the basis of their virulence,