three-tier internet project - spring 2005 server-side language – eg java server pages data base...

23
Three-Tier Internet Project - Spring 2005 Server-side Language – eg JAVA Server Pages Data Base –eg MS Access with SQL Tomcat -- or Apache server Simple Javascripts The project can be done in a team of two persons. You must indicate Who is on your team. You can do acceptable variations on this project – but you must che with me to get approval. The sky's the Limit on the variations.

Post on 22-Dec-2015

218 views

Category:

Documents


2 download

TRANSCRIPT

Three-Tier Internet Project - Spring 2005

Server-side Language – eg JAVA Server Pages

Data Base –eg MS Access with SQL

Tomcat -- or Apache server

Simple Javascripts

The project can be done in a team of two persons. You must indicateWho is on your team.

You can do acceptable variations on this project – but you must checkwith me to get approval. The sky's the Limit on the variations.

Make a server-based Testing - or Questionnaire - system

Version-1. System allows user to Log on to system using name & passwordLets user start (trivial) session.

Version-2. System gets a question from database, sends to user, gets response back from user, checks response against correct answer in database, logs user's response & score in database, reports result to user.

Version-3. System orchestrates sequence of questions from database, sends one at time to user, gets response back from user, checks response against correct answer in database, logs user's response, reports result to user, sends next question, at end logs user's score & sends score to user.

Version-4. System limits amount of time allowed per question.

Name

Password

Logon

Name

Password

Logon

Server program

1. Checks User table in database for permissions.

Userstable

2. Creates entry in User-Test table for user, score, etc

3. Gets question from Question table.

User-Test table

Questionstable

4. Sends question to user.

User-name User-password

Userstable

User-Test table

Questionstable

Question-Number Question-string Question-answer

Answer-1 Answer-2 Answer-4Answer-3

Current-question-number

User-Answer-to-1

Score-so-far-on-Test

User-Answer-to-2 ... User-Answer-to-10

User-name User-password Test-Number

Database Tables

Server program

1. Gets answer from user

2. Checks answer against Question table

3. Logs answer & score-so-far in User-Test table

User-Testtable

Questiontable

4. Sends result to user.

The question is: Who is the First President of U.S.?

Submit answer

Answer-1 Answer-2 Answer-3 Answer-4

(and: question number & user identity as hidden html data)

Remember – the server-side

program does not automatically

remember you !

The successive enhancements are:

1. Permit system to send:

multiple questions: one-at-a-time -- OR– in a batch.

2. Let server-side program reject answers submitted after a prescribed time-delay.

This can be done by sending a Javascript-based timer to the client.The timer could, for example, send the user a warning when the time is upand also send the time taken to the server so the server can check if there was an overtime and act accordingly.

Technical Issues

The number of the next question to be sent to the user has to be maintained on the server. For example, it could be kept in the User-test-table in the database.

This could be accomplished via a hidden field sent in the user's html form which is automatically sent back to the server when the question is completed– or – alternatively by a cookie sent to the user's browser -

Remembering what question comes next:

But the server still has to also know which user it is interacting with - since different users can come and go, and several user's could be testing at the same time.

Enhancement Issues

The issue here to let the server reject answers which are submitted after a prescribed time-delay: they count as wrong answers.

This could be achieved by sending a Javascript-based timer to the client.

Recognizing & Enforcing Time Limit violations:

Scenarios

of Use

1. User accesses home page

Name

Password

Logon

Name

Password

Logon

John Doe

magic007

2. User logs on & submits info:

3. System verifies user data

Name

Password

John Doe

Magic007

Users table

User-name User-password

Harry Byrd 000RRRQQQ

John Doe Magic007

4. If valid user, system accesses User-Test Table and the Question table

1: Who is the First President of U.S.?

Submit answer

Lincoln

George III

Washington

Peter rabbit

Question table

Num Question Choices Answer

... ... ...Sends Question #1 to client

User-Test table

Next-Q: 1

User-Name User-Password

Res-1 Res--2 ...

Ans-1 Ans-2 ...

Score-so-far

Results logged here

6. System checks & logs result

5. User submits answer

User-Test table

Next-Q: 2

Res-1: 0 ........

User-Name User-Password

Ans-1: 1 .......

Score-so-far: 0 pts

Question table

Question Choices Answer

... ... 3

1: Who is the First President of U.S.?

Submit answer

Lincoln

George III

Washington

Peter Rabbit

1

2

3

4

6. System checks & logs result

User-Test table

Next-Q: 2

Res-1: 0 ........

User-Name User-Password

Ans-1: 1 .......

Score-so-far: 0 pts

Question table

Num Question Choices Answer

1: ... ... 3

1: Who is the First President of U.S.?

Submit answer

Lincoln

George III

Washington

Peter Rabbit

1

2

3

4

Currently question #1

hidden HTML fields determine customerand question number

Correct answer for Q-1 was #3

Tables let you handle question

User-Test table

Next-Q: 2

Res-1: 0 ........

User-Name User-Password

Ans-1: 1 .......

Score-so-far: 0 pts

Question table

Num Question Choices Answer

1: ... ... 3

1: Who is the First President of U.S.?

Submit answer

Lincoln

George III

Washington

Peter Rabbit

1

2

3

4

Ans-1 etc – attributes in table

built in JSP as strings: "Ans-" + "Question-Num"

Server

Also sends hidden data in HTML so server can "remember" what's up:

Logs result by updating database tables

Sends next question to user

User name

User password

Current question number

homePage

Html-1

badInvaliduser

Jsp-1-results'

Passwordcheck

Jsp-1

data

good

Click toStartQuiz

Jsp-1-results: Form

dataRefer to: q00.html qJSP2.jsp qJSP3.jspin Chapter 11

See also: p00.html p011.jsp project2005.mdbfor skeleton of different approach.

Click toStartQuiz

Jsp-1-results: HTML Form

Data

1. Evaluate answer2. If done Else more

Jsp-3

1.Get question2.Send page with question.

Jsp-2

Data

Data

JSP-3 does:1.Gets score2.Send page with score.

Jsp-4

Data

Jsp-2-results: HTML Form

1. Question2. Button3. Hidden data.

DataData: user name current question number (?) answer (?)

out.println (" " ) ;

Request qJSP2.jsp

redirects browser url

Careful: Single quotes at each end only

How to request execution of one JSP page from another JSP page

from qJSP3.jsp

including data qJSP2 requires:

<script> </script>window.location='qJSP2.jsp?mName= zorro'

window.location = 'qJSP2.jsp ? mName= zorro '

request program

name expected HTML field & value

– and also send it data

– in your qJSP3.jsp code -

qJSP3.jsp qJSP2.jspmName= zorro

Demonstrate

<html><head></head><body><script> window.location='qJSP2.jsp?mName= zorro'</script></body></html>

Using server – to see how the page automatically requests qJSP2.jsp

out.println

( "<html><head></head><body> <form action='qJSP3.jsp' > " +

"<input type = text name='newName' value =" + sTemp +

" /><input type ='submit' ></form> " );

Send an HTML Form to browser (from qJSP2 example):

Use System.out to send info to dos prompt.