eclipse

profileebra

So far, our dynamic web page is not very dynamic: no matter how many times you reload the

page, it will always be the same. In most of our work, what will make pages dynamic is the fact

that they are pulling information from the database and responding to user input. But those both

require a bunch of new technology, we will be learning about those in subsequent labs. Instead,

we will get some dynamic behavior from random numbers.

While it is used in some special ways and has some special capabilities, a servlet is just a Java

class like any other, and you can do anything in it that any other Java class can do.

Below the existing paragraph, add a level-1 heading that says, “Your lucky numbers for

today”.

Inside the doGet method, create an array of 20 integers, and fill it with 20 random numbers.

Then include in the HTML output a table in which each row contains two columns. The first

column counts down from 20 to 1, and the second displays the random numbers in the array,

from first to last. (You’ll have to do some slightly fancy arithmetic, since the first column values

are decreasing while the array indices are increasing).

Use CSS in an internal style sheet to:

• put all the random numbers (but not the counters) in a monospaced font

• to center the table

• to put borders around all of the cells in the table

Add a paragraph below the table that says either “Your luckiest number is even!” or “Your

luckiest number is odd!”, whichever is true. The last number in the array is the user’s luckiest

number.

    • 7 years ago
    • 20
    Answer(1)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      java-fortune-servlet.zip