| Lisa Tolliver | 11/21/2002 | 8:09:47 PM | Never mind, I guess we can use the web board. | |
| Haomin Wang | 11/21/2002 | 8:10:20 PM | As far as I can tell from assignments turned in, Bruce Long, and Cliff de Long | |
| Haomin Wang | 11/21/2002 | 8:10:40 PM | and you and Marsha | |
| Haomin Wang | 11/21/2002 | 8:11:44 PM | I've just posted some additional notes on Week 12 assignments for Track II | |
| Marsha Utech | 11/21/2002 | 8:12:08 PM | I have rechecked my driver and it is there in odbc but when I run it in tomcat, its not finding it. I'm still trying because I would really like to know more about databases. | |
| Haomin Wang | 11/21/2002 | 8:12:14 PM | for this assignment, you'll need to use arrays in Java | |
| Haomin Wang | 11/21/2002 | 8:12:56 PM | Marsha: you mean you couldn't find the database when you tried to set up the DSN? | |
| Marsha Utech | 11/21/2002 | 8:13:36 PM | No, I found everything and it looks like it is set in stone, untill I run it on tomcat | |
| Haomin Wang | 11/21/2002 | 8:13:53 PM | what error message did you get? | |
| Marsha Utech | 11/21/2002 | 8:14:16 PM | internal error() | |
| Marsha Utech | 11/21/2002 | 8:14:26 PM | I read that it could not find the name driver | |
| Marsha Utech | 11/21/2002 | 8:14:49 PM | Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified | |
| Lisa Tolliver | 11/21/2002 | 8:15:22 PM | Haomin, I had a hard time with the arrays in the first half of this class. Is there some way you can explain them in a simplified version? | |
| Haomin Wang | 11/21/2002 | 8:15:22 PM | Your DSN was not set up properly then | |
| Haomin Wang | 11/21/2002 | 8:16:01 PM | Lisa: an array is a group of items organized as a cluster | |
| Marsha Utech | 11/21/2002 | 8:16:03 PM | I typed USstates in the DSN and selected My Documents as a directory | |
| Haomin Wang | 11/21/2002 | 8:17:16 PM | Marsha: the point is not to type "UStates" (because you can type in a different name. The point is to have the correct driver on the computer and set up the correct connection | |
| Haomin Wang | 11/21/2002 | 8:17:59 PM | The reason for using an array is mainly to store and access data using an index value | |
| Haomin Wang | 11/21/2002 | 8:18:44 PM | Marsha: Where did you run your Tomcat? On a laptop or desktop? | |
| Haomin Wang | 11/21/2002 | 8:19:20 PM | For example, when we store 50 states in an array, we can access any one of them using a specific index value | |
| Haomin Wang | 11/21/2002 | 8:20:00 PM | this principle is important in database work | |
| Marsha Utech | 11/21/2002 | 8:20:48 PM | I can't believe, it I don't know what I did, but it is now working, wow that took awhile thanks for being patient Haomin | |
| Haomin Wang | 11/21/2002 | 8:21:22 PM | Marsha: are you seeing data displayed? | |
| Marsha Utech | 11/21/2002 | 8:21:31 PM | Yes I am! | |
| Marsha Utech | 11/21/2002 | 8:21:46 PM | Connection is: sun.jdbc.odbc.JdbcOdbcConnection@1719f30 Statement is: sun.jdbc.odbc.JdbcOdbcStatement@bfbbe3 | |
| Haomin Wang | 11/21/2002 | 8:21:49 PM | then you made it! | |
| Roxanne Everhard | 11/21/2002 | 8:22:16 PM | Hello everyone | |
| Haomin Wang | 11/21/2002 | 8:22:35 PM | These two values are dynamic. they can change each time you connect to the database Connection is: sun.jdbc.odbc.JdbcOdbcConnection@1719f30 Statement is: sun.jdbc.odbc.JdbcOdbcStatement@bfbbe3 | |
| Haomin Wang | 11/21/2002 | 8:22:53 PM | Hi, Roxanne | |
| Haomin Wang | 11/21/2002 | 8:23:17 PM | Roxanne: did you have a chance to review the sample script I sent you? | |
| Marsha Utech | 11/21/2002 | 8:23:28 PM | okay thanks, to change colors or anything of that sort, it is always within the script , correct | |
| Haomin Wang | 11/21/2002 | 8:24:00 PM | depending on which part of the page | |
| Haomin Wang | 11/21/2002 | 8:24:14 PM | if it's the page background, it's in the body tag | |
| Haomin Wang | 11/21/2002 | 8:24:32 PM | if it's table background, it's in the table tag | |
| Haomin Wang | 11/21/2002 | 8:24:58 PM | if it's a table row, it's in | |
| Roxanne Everhard | 11/21/2002 | 8:25:31 PM | Yes, and I resent another to you last night. | |
| Haomin Wang | 11/21/2002 | 8:25:43 PM | or color can be applied to a table cell | |
| Marsha Utech | 11/21/2002 | 8:26:08 PM | what about text color? | |
| Roxanne Everhard | 11/21/2002 | 8:26:23 PM | Although I gave up on have the checkboxes with all the answers being correct... didn't figure out how to do that | |
| Haomin Wang | 11/21/2002 | 8:26:35 PM | I haven't been able to read your last email then, Roxanne. I'll get back to you tomorrow morning | |
| Roxanne Everhard | 11/21/2002 | 8:26:44 PM | ok | |
| Haomin Wang | 11/21/2002 | 8:27:24 PM | I can't believe there could be this many emails piled up in my mail box within 5 days | |
| Marsha Utech | 11/21/2002 | 8:27:41 PM | ignore my e-mail I sent tonight | |
| Haomin Wang | 11/21/2002 | 8:28:13 PM | text color is text here | |
| Haomin Wang | 11/21/2002 | 8:28:49 PM | don't forget the closing tag | |
| Marsha Utech | 11/21/2002 | 8:28:59 PM | ok thanks | |
| Haomin Wang | 11/21/2002 | 8:29:10 PM | otherwise, the font setting can extend all the way down | |
| Cliff De Long | 11/21/2002 | 8:29:11 PM | 17519 total for 18 months in my inbox (unsorted) | |
| Paulette Mangold | 11/21/2002 | 8:30:02 PM | you were saying about the arrays? | |
| Haomin Wang | 11/21/2002 | 8:30:03 PM | Some more efficient ways have to be found for processing emails | |
| Haomin Wang | 11/21/2002 | 8:30:35 PM | Hi, Paulette. Yes, we discussed arrays briefly | |
| Paulette Mangold | 11/21/2002 | 8:30:51 PM | hello | |
| Haomin Wang | 11/21/2002 | 8:31:11 PM | Weelk 5 has the most discussion on arrays | |
| Roxanne Everhard | 11/21/2002 | 8:31:17 PM | [Private] Ughh...unsorted? That would drive me insane. The other day I showed some people at school how to use folders to organize their email and they were sooooo impressed. It's good to feel smart sometimes! | |
| Paulette Mangold | 11/21/2002 | 8:31:33 PM | I didn't really understand that either | |
| Haomin Wang | 11/21/2002 | 8:31:43 PM | with database, arrays will be more frequently used | |
| Kim Larson | 11/21/2002 | 8:33:04 PM | I have a question about Track 1 - week 12 | |
| Haomin Wang | 11/21/2002 | 8:33:16 PM | go ahead, Kim | |
| Lisa Tolliver | 11/21/2002 | 8:33:50 PM | No wonder you don't reply, Cliff! | |
| Kim Larson | 11/21/2002 | 8:33:54 PM | I have the menus working, but can't figure out how to change the number of items in the menu | |
| Kim Larson | 11/21/2002 | 8:34:31 PM | Does it have to do with the length? | |
| Lisa Tolliver | 11/21/2002 | 8:34:54 PM | Haomin, I've read Ch. 22 in the book, and also gone back to our previous chapters about arrays, and can't seem to find anything on sorting within an array | |
| Haomin Wang | 11/21/2002 | 8:35:00 PM | First of all, you add the URL in the menu item list
Auto Bytel Auto Vantage cars direct Kelly Blue Book | |
| Kim Larson | 11/21/2002 | 8:35:30 PM | OK | |
| Lisa Tolliver | 11/21/2002 | 8:35:37 PM | Also, as I said, I can get the states in order both MAX and MIN, but cannot figure out how to get the largest and smallest 3 instead of just 1 | |
| Haomin Wang | 11/21/2002 | 8:35:50 PM | Lisa: we can do the 6 states without sorting. I'll get back to that later | |
| Lisa Tolliver | 11/21/2002 | 8:35:56 PM | ok | |
| Haomin Wang | 11/21/2002 | 8:36:07 PM | To add a menu item
Auto Bytel Auto Vantage cars direct Kelly Blue Book | |
| Haomin Wang | 11/21/2002 | 8:37:24 PM | Auto Bytel Auto Vantage cars direct new link | |
| Kim Larson | 11/21/2002 | 8:38:13 PM | That would still only give you 4, but what if I want 3 or 5 items in the list? | |
| Roxanne Everhard | 11/21/2002 | 8:38:13 PM | I'm starting on week 10...is anyone familiar with searching within BigChalk.com...do they use frames? | |
| Haomin Wang | 11/21/2002 | 8:38:39 PM | Here's a better one:
Auto Bytel Auto Vantage cars direct Kelly Blue Book New Link | |
| Haomin Wang | 11/21/2002 | 8:39:03 PM | or
Auto Bytel Kelly Blue Book New Link | |
| Kim Larson | 11/21/2002 | 8:39:57 PM | So is that the only place you need to change? Only change the lines with the links? | |
| Haomin Wang | 11/21/2002 | 8:39:59 PM | then you need to adjust the top attribute values in:
Lessons > Week 12 > (JavaScript) > Page 1 > Page 2 > Page 3
Pull-Down Menus
We don't have to use existing image files to create graphics in a Web page. Dynamic HTML and JavaScript allow us to use the object properties of modern browsers to create graphs and image. In Chapter 13 of Negrino & Smith's book, we have examples of pull-down menus and and sliding menus. These menus can be useful when we have more content than the space in a Web page can allow.
To create interactive menus, we need to use Cascading Style Sheet (CSS). Here's an adapted version of the pull-down menu example from Chapter 13 of Negrino & Smith's book. You may also need to refer back to the lesson notes of Week 9 for some basics of CSS, particularly the concept of class in CSS. There are a few points we need to explain here:
1. First of all, we need to create two classes for two different menus: menu1 and menu2. In this example, the two menu classes differ only in one attribute: the distance from the browser window top border, because the two menus have different number of items and therefore different heights. Note that the two class names are used in the HTML body section to refer back to the classes.
2. The second type of selector we use is the ID tag. Like a class, an ID tag encloses a block of format definitions. Compared with ID, a class is more generic in scope, whereas an ID is more specific. We can use both a class and an ID to apply formatting definitions to parts of text in a top-down cascading manner. In our example, two IDs are created: #searchMenu1 and #searchMenu2. The two IDs take arguments specifying the distance each menu should have from the left border of the browser window, and their widths. You may review pp. 250-251 of Negrino & Smith's book on ID in CSS.
3. In the HTML body, we use the tag to create block level CSS. Each DIV has an ID which equals the ID created earlier in the style definitions. Each DIV also has | |
| Haomin Wang | 11/21/2002 | 8:41:06 PM | I'm sorry; copied too much. Here's what it was supposed to be: .menu1 { position:absolute; font:12px arial, helvetica, sans-serif; background-color:#cccc99; layer-background-color:#CCCC99; top:-120px; padding: .2em } .menu2 { position:absolute; font:12px arial, helvetica, sans-serif; background-color:#cccc99; layer-background-color:#CCCC99; top:-90px; padding: .2em } | |
| Kim Larson | 11/21/2002 | 8:42:12 PM | So the top: -90px line is the one you would change - smaller number for shorter list and larger number for longer list? | |
| Haomin Wang | 11/21/2002 | 8:42:48 PM | You may also need to change the value in the toggleMenu() function onMouseout="toggleMenu('searchMenu1',-112) | |
| Haomin Wang | 11/21/2002 | 8:43:20 PM | The value -112 specifies the vertical position of the menu when the mouse moves out of the menu | |
| Haomin Wang | 11/21/2002 | 8:44:37 PM | 0 is the border position. Minus values are above the border (out of the window and become invisible). Positive is below the boder (visible) | |
| Kim Larson | 11/21/2002 | 8:46:12 PM | OK, thanks - I will work with that and let someone else ask questions. | |
| Haomin Wang | 11/21/2002 | 8:48:24 PM | I modified the sample pull-menus a litte. You may want to take a look at http://courses.dsu.edu/cet756/lessons/Week12/pulldown_menus.htm | |
| Kim Larson | 11/21/2002 | 8:48:59 PM | Thanks | |
| Haomin Wang | 11/21/2002 | 8:50:32 PM | Lisa and Paulette: do you want to further disucss arrays? | |
| Lisa Tolliver | 11/21/2002 | 8:51:18 PM | yes, please | |
| Paulette Mangold | 11/21/2002 | 8:51:20 PM | I would | |
| Lisa Tolliver | 11/21/2002 | 8:51:58 PM | Just mainly how to find the 3 instead of 1 | |
| Haomin Wang | 11/21/2002 | 8:52:29 PM | Let's have an analogy. Say, you have a pile of sticks that you want to put into order, what could you do? | |
| Paulette Mangold | 11/21/2002 | 8:53:01 PM | sort by size | |
| Haomin Wang | 11/21/2002 | 8:53:06 PM | You can align them into a row, and then shift their positions | |
| Haomin Wang | 11/21/2002 | 8:53:12 PM | right! | |
| Haomin Wang | 11/21/2002 | 8:53:41 PM | when you put them into a row, you can visualize them as an array | |
| Haomin Wang | 11/21/2002 | 8:54:04 PM | a grooup of objects that are of the same type, but different values | |
| Lisa Tolliver | 11/21/2002 | 8:54:23 PM | got it | |
| Paulette Mangold | 11/21/2002 | 8:54:39 PM | me too | |
| Haomin Wang | 11/21/2002 | 8:54:42 PM | and you need to put them in order so that you can access any one of them in a specific way | |
| Lisa Tolliver | 11/21/2002 | 8:55:02 PM | okay | |
| Haomin Wang | 11/21/2002 | 8:55:19 PM | it's like lining up a grooup students in accordance with their heights | |
| Paulette Mangold | 11/21/2002 | 8:55:46 PM | but the trick is to ask the right questions to get the right ones to step forward | |
| Cliff De Long | 11/21/2002 | 8:55:50 PM | If we create an MSaccess db on a workstation and then upload it to a TomCat directory, can it be modified w/ a JSP script if neither MSaccess or MSsql is installed? If so, what would the rudimentary steps to this task be? | |
| Haomin Wang | 11/21/2002 | 8:56:29 PM | then you can order out either the tallest or the shortest or the one in the middle | |
| Haomin Wang | 11/21/2002 | 8:57:13 PM | The array index is the key | |
| Haomin Wang | 11/21/2002 | 8:57:55 PM | An array must have a size so that you know which is the last element | |
| Haomin Wang | 11/21/2002 | 8:58:21 PM | If you use an index value that's out of an array's size, error message pop up | |
| Haomin Wang | 11/21/2002 | 8:59:25 PM | Cliff: a database can be placed anywhere on your computer, though it's usually suggested that you don't place in an open web directory | |
| Haomin Wang | 11/21/2002 | 9:00:04 PM | So, whether it's MS Access or MySQL, you can place it directly under C or "My Documents" or on your Desktop | |
| Haomin Wang | 11/21/2002 | 9:00:54 PM | The important part is to find the database and set up the right path when you set up the DSN | |
| Marsha Utech | 11/21/2002 | 9:00:55 PM | I'm curious, after week 14 how long do we have to turn in our assignments? | |
| Lisa Tolliver | 11/21/2002 | 9:01:32 PM | so should the array stop after 2 (0, 1 and 2)? | |
| Haomin Wang | 11/21/2002 | 9:01:59 PM | depending how many assignments are undue before I send the final grades to the registrar | |
| Marsha Utech | 11/21/2002 | 9:02:45 PM | When is the latest date that you will send final grades? | |
| Haomin Wang | 11/21/2002 | 9:03:08 PM | If you send 5 assignments one day before I send in the final grades, I may not be able to read and grade them all. In that case, you may get an "I" grade | |
| Haomin Wang | 11/21/2002 | 9:03:40 PM | I think it's Dec 20 | |
| Cliff De Long | 11/21/2002 | 9:04:03 PM | I'm throwing it right in the Tomcat directory of a terminal server - C:\Program Files\Apache Group\Tomcat 4.1\webapps\examples\jsp\ ... But, my question is, what would I put in a script to modify entries in the *.mdb file? | |
| Marsha Utech | 11/21/2002 | 9:04:39 PM | Thank you, I am signing off now | |
| Lisa Tolliver | 11/21/2002 | 9:05:00 PM | Haomin, back to the arrays | |
| Haomin Wang | 11/21/2002 | 9:05:03 PM | You mean changing data in a table? | |
| Lisa Tolliver | 11/21/2002 | 9:05:09 PM | should we stop after 2? | |
| Haomin Wang | 11/21/2002 | 9:05:23 PM | OK. arrays | |
| Haomin Wang | 11/21/2002 | 9:05:51 PM | Now that you have the gorup of students lined up, you have an array | |
| Haomin Wang | 11/21/2002 | 9:06:14 PM | and you can pick any one of them by a sequence number | |
| Haomin Wang | 11/21/2002 | 9:06:26 PM | that's like an array index value | |
| Cliff De Long | 11/21/2002 | 9:06:38 PM | [Private to Haomin Wang] I'll wait - just holler when ererybody else gets done. | |
| Lisa Tolliver | 11/21/2002 | 9:06:57 PM | So would I have 6 different lines choosing 0, 1, 2, and some how the last three? | |
| Lisa Tolliver | 11/21/2002 | 9:07:19 PM | or just 0, 1, and 2 and then reverse the order and choose 0, 1, and2 again? | |
| Haomin Wang | 11/21/2002 | 9:08:01 PM | OK. Lisa. I'm copying an array here: String stateNames [] = {"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"}; | |
| Haomin Wang | 11/21/2002 | 9:08:28 PM | Here's another: long stateAreas [] = {52423,656425,114006,53182,163707,104100,5544,2489,65758,59441,10932, 83574,57918,36420,56276,82282,40411,51843,35387,12407,10555,38192,86943, 48434,69709,147046,77358,110567,9351,8722,121593,54475,53821,70704,44828, 69903,98386,46058,1545,32007,77121,42146,268601,84904,9615,42769,71303, 24231,65503,97818}; | |
| Haomin Wang | 11/21/2002 | 9:08:50 PM | Each state is separared from others by a comma | |
| Paulette Mangold | 11/21/2002 | 9:09:08 PM | got that | |
| Lisa Tolliver | 11/21/2002 | 9:09:43 PM | I understand all of that clearly, I just don't get how to find 3 specific ones at a time instead of just one at a time | |
| Haomin Wang | 11/21/2002 | 9:10:00 PM | Hold on. I'm pulling out another array | |
| Haomin Wang | 11/21/2002 | 9:13:52 PM | Can you access this page: http://www.courses.dsu.edu/cet756/lessons/Week12/states.htm | |
| Paulette Mangold | 11/21/2002 | 9:14:11 PM | yes | |
| Lisa Tolliver | 11/21/2002 | 9:14:39 PM | yes | |
| Haomin Wang | 11/21/2002 | 9:14:51 PM | OK. If you have this array (actually two arrays), can you easily pick out the three largest and three smallest? | |
| Lisa Tolliver | 11/21/2002 | 9:15:09 PM | right, I've figured out those 2 arrays | |
| Haomin Wang | 11/21/2002 | 9:15:12 PM | If you scroll down, they are there | |
| Paulette Mangold | 11/21/2002 | 9:16:24 PM | ok | |
| Lisa Tolliver | 11/21/2002 | 9:16:36 PM | I actually just wrote mine so they were in one table, but I used the area < and area > a certain number | |
| Haomin Wang | 11/21/2002 | 9:16:37 PM | If we place them in two arrays: one named stateNames and the other stateAreas, we can then access the first three (smallest) by picking stateNames[0], stateNames[1], and stateNames[2] | |
| Haomin Wang | 11/21/2002 | 9:16:56 PM | and of course, stateAreas[0], stateAreas[1], and stateAreas[2] | |
| Lisa Tolliver | 11/21/2002 | 9:17:21 PM | would that be a get... I can't remember the word | |
| Haomin Wang | 11/21/2002 | 9:17:34 PM | what about the last three (largest), given that we know the array size is 50? | |
| Lisa Tolliver | 11/21/2002 | 9:17:36 PM | My book is at school | |
| Lisa Tolliver | 11/21/2002 | 9:17:51 PM | 47,48, and 49 | |
| Lisa Tolliver | 11/21/2002 | 9:18:02 PM | but what if we don't know the array size? | |
| Haomin Wang | 11/21/2002 | 9:18:08 PM | stateStates[0] = request.getString("name") | |
| Lisa Tolliver | 11/21/2002 | 9:18:21 PM | that's it - getString | |
| Haomin Wang | 11/21/2002 | 9:18:29 PM | stateNames[0] = request.getString("namej") | |
| Lisa Tolliver | 11/21/2002 | 9:18:42 PM | do we write that 6 times? | |
| Haomin Wang | 11/21/2002 | 9:18:54 PM | stateAreas[0] = request.getLong("area") | |
| Haomin Wang | 11/21/2002 | 9:19:03 PM | of course not | |
| Haomin Wang | 11/21/2002 | 9:19:09 PM | use loops | |
| Lisa Tolliver | 11/21/2002 | 9:19:39 PM | or stateNames[0,1,2,47,48,49] = request.getString("name") | |
| Haomin Wang | 11/21/2002 | 9:19:39 PM | arrIndex = 0; while(results.next()) { stateNames[arrIndex] = results.getString("name"); areaSize[arrIndex] = results.getLong("area"); arrIndex++; } | |
| Haomin Wang | 11/21/2002 | 9:20:03 PM | No, you can't do that | |
| Lisa Tolliver | 11/21/2002 | 9:20:06 PM | ok | |
| Lisa Tolliver | 11/21/2002 | 9:20:46 PM | but when will the array stop? | |
| Haomin Wang | 11/21/2002 | 9:20:52 PM | you can't cram so many numbers into the square brackets | |
| Haomin Wang | 11/21/2002 | 9:21:12 PM | when results has no more "next" | |
| Lisa Tolliver | 11/21/2002 | 9:21:28 PM | won't that show all 50 then? | |
| Paulette Mangold | 11/21/2002 | 9:21:36 PM | that's what I thought | |
| Haomin Wang | 11/21/2002 | 9:21:56 PM | in this case, we know the array won't go over 50, so we declare the array size to be 50 | |
| Lisa Tolliver | 11/21/2002 | 9:22:18 PM | is that the arrIndex? | |
| Haomin Wang | 11/21/2002 | 9:22:30 PM | int stateAreas [ ] = new int [50]; String stateNames [ ] = new String [50]; | |
| Haomin Wang | 11/21/2002 | 9:22:58 PM | yes. "arrIndex" is declared to be an integer | |
| Haomin Wang | 11/21/2002 | 9:23:08 PM | int arrIndex = 0; | |
| Haomin Wang | 11/21/2002 | 9:23:42 PM | it gets incremented each time the results set gets a record | |
| Haomin Wang | 11/21/2002 | 9:24:08 PM | so that the next record can be placed in the next element of the array | |
| Lisa Tolliver | 11/21/2002 | 9:25:35 PM | are you still in an array, or now in a loop? | |
| Haomin Wang | 11/21/2002 | 9:26:08 PM | array and loop have to work together to display their power | |
| Haomin Wang | 11/21/2002 | 9:26:31 PM | How can we go through an array most efficiently? | |
| Haomin Wang | 11/21/2002 | 9:26:39 PM | say, the array has 100 elements | |
| Haomin Wang | 11/21/2002 | 9:26:48 PM | using a loop | |
| Lisa Tolliver | 11/21/2002 | 9:27:10 PM | right, but what if we don't know how many elements are in the array? | |
| Haomin Wang | 11/21/2002 | 9:27:36 PM | for (int k=0; k<100; k++) { println ( array[k] ); } | |
| Lisa Tolliver | 11/21/2002 | 9:27:38 PM | How can we just ask "what are the three largest and the 3 smallest" and it will work in any database? | |
| Haomin Wang | 11/21/2002 | 9:28:20 PM | you can use the property length to find out
for (int k=0; k | |
| Haomin Wang | 11/21/2002 | 9:28:43 PM | k will never exceed the array length (size) | |
| Lisa Tolliver | 11/21/2002 | 9:29:09 PM | ok, I actually understand that little bit | |
| Haomin Wang | 11/21/2002 | 9:29:15 PM | access the first thee and then the last three elements in the array | |
| Haomin Wang | 11/21/2002 | 9:29:43 PM | let the loop run 3 times accessing the first three | |
| Haomin Wang | 11/21/2002 | 9:30:02 PM | and another loop 3 more times, but accessing the last three elements of the array | |
| Lisa Tolliver | 11/21/2002 | 9:30:38 PM | I think I might be able to figure out the first 3 by incrementing by one 3 times, but how would you find the last 3? | |
| Haomin Wang | 11/21/2002 | 9:30:50 PM | Actually, I would put all the state names and areas into an array of 50 | |
| Lisa Tolliver | 11/21/2002 | 9:31:00 PM | That's what I did | |
| Lisa Tolliver | 11/21/2002 | 9:31:07 PM | well, sort of | |
| Haomin Wang | 11/21/2002 | 9:31:14 PM | and then simplly write 6 states to retrieve the data from the array | |
| Lisa Tolliver | 11/21/2002 | 9:31:30 PM | I have them all in one table with the state names and areas in MAX or MIN order | |
| Lisa Tolliver | 11/21/2002 | 9:32:06 PM | give me a hint on that one | |
| Lisa Tolliver | 11/21/2002 | 9:32:17 PM | I'm not following you | |
| Haomin Wang | 11/21/2002 | 9:32:53 PM | println(stateNames[0] + stateAreas[0]): println(stateNames[1] + stateAreas[1]): println(stateNames[2] + stateAreas[2]): ///////////////////////////////// println(stateNames[47] + stateAreas[47]): println(stateNames[48] + stateAreas[48]): println(stateNames[49] + stateAreas[49]): | |
| Haomin Wang | 11/21/2002 | 9:33:39 PM | The query can select all states in ascending order: results = stmt.executeQuery("select name, area from states order by area"); | |
| Haomin Wang | 11/21/2002 | 9:33:47 PM | ordered by area | |
| Lisa Tolliver | 11/21/2002 | 9:34:05 PM | OHHHH, I was trying to find a way to say something with the statenames and stateAreas together, not separate like you put it. | |
| Haomin Wang | 11/21/2002 | 9:34:26 PM | int arrIndex = 0; while(results.next()) { stateNames[arrIndex] = results.getString("name"); areaSize[arrIndex] = results.getLong("area"); arrIndex++; } | |
| Lisa Tolliver | 11/21/2002 | 9:34:31 PM | that's the exact statement I have in my script so far | |
| Haomin Wang | 11/21/2002 | 9:34:53 PM | did you put them in arrays | |
| Lisa Tolliver | 11/21/2002 | 9:35:16 PM | I have: results = stmt.exectueQuery("select name, area from states order by area"); | |
| Lisa Tolliver | 11/21/2002 | 9:35:54 PM | I think so, because it shows the table with all 50 states and their areas | |
| Haomin Wang | 11/21/2002 | 9:35:57 PM | you need to put the results into arrays so that you can access the first three and last three by index values | |
| Lisa Tolliver | 11/21/2002 | 9:36:05 PM | oh...okay | |
| Lisa Tolliver | 11/21/2002 | 9:36:18 PM | so put the results from MAX and MIN in an array? | |
| Haomin Wang | 11/21/2002 | 9:36:41 PM | actually, there's a shortcut | |
| Lisa Tolliver | 11/21/2002 | 9:36:46 PM | or put the 50 state names in ABC order in an array with their respective areas? | |
| Haomin Wang | 11/21/2002 | 9:36:51 PM | no MAX or MIN needed | |
| Lisa Tolliver | 11/21/2002 | 9:36:55 PM | oh | |
| Haomin Wang | 11/21/2002 | 9:37:54 PM | When you display the results in a table, use a counter to display only # 1, 2, 3, and # 47, 48, and 49 | |
| Lisa Tolliver | 11/21/2002 | 9:39:11 PM | where can I refresh my memory about counters/ | |
| Haomin Wang | 11/21/2002 | 9:41:55 PM | int counter = 0; while(results.next()) { counter++; if (counter < 4 && counter < 47) { out.println(" | |
| " + results.getString("name") + " | "); out.println("" + results.getLong("population") + " | "); out.println("|||
| Haomin Wang | 11/21/2002 | 9:42:45 PM | I'm sorry; it should be: if (counter < 4 && counter > 46) | |
| Lisa Tolliver | 11/21/2002 | 9:42:52 PM | shouldn't that be" if | |
| Lisa Tolliver | 11/21/2002 | 9:42:59 PM | yep, that's what I was going to write | |
| Haomin Wang | 11/21/2002 | 9:43:08 PM | no, it should be: if (counter < 4 || counter < 47) | |
| Haomin Wang | 11/21/2002 | 9:43:38 PM | meaning if counter is either less than 4 or counter is greater than 46 | |
| Lisa Tolliver | 11/21/2002 | 9:43:59 PM | wouldn't it be counter > 47 (using the greater than sign)? | |
| Haomin Wang | 11/21/2002 | 9:44:05 PM | so the correct condition is: if (counter < 4 || counter > 46) | |
| Paulette Mangold | 11/21/2002 | 9:44:17 PM | I think counters are in chapter 8 of Deitel | |
| Lisa Tolliver | 11/21/2002 | 9:44:25 PM | ok | |
| Paulette Mangold | 11/21/2002 | 9:44:36 PM | ok | |
| Haomin Wang | 11/21/2002 | 9:44:51 PM | it'll display state names and areas only when the counter is 1, 2, 3, 47, 48, 49 | |
| Lisa Tolliver | 11/21/2002 | 9:45:07 PM | I'm going to try to work on this much of it tomorrow, and I'll e-mail you if I have further questions | |
| Paulette Mangold | 11/21/2002 | 9:45:13 PM | thank you | |
| Haomin Wang | 11/21/2002 | 9:45:27 PM | counter is only an integer that gets updated on a regular basis | |
| Haomin Wang | 11/21/2002 | 9:45:43 PM | OK | |
| Lisa Tolliver | 11/21/2002 | 9:45:46 PM | One quick question | |
| Lisa Tolliver | 11/21/2002 | 9:45:54 PM | what if you don't know the length of the array? | |
| Haomin Wang | 11/21/2002 | 9:46:18 PM | you can find it out by using the length property of an array | |
| Lisa Tolliver | 11/21/2002 | 9:46:37 PM | is there a way to just ask it to give you the last 3 in the length property? | |
| Haomin Wang | 11/21/2002 | 9:46:56 PM | arrayName.length should give you an integer value of the array's size | |
| Lisa Tolliver | 11/21/2002 | 9:47:12 PM | ok | |
| Haomin Wang | 11/21/2002 | 9:47:33 PM | if arrayName.length is 50, you know the last three should be indexed as 47, 48, and 49 | |
| Haomin Wang | 11/21/2002 | 9:48:46 PM | do you think you've come to grips with arrays | |
| Paulette Mangold | 11/21/2002 | 9:48:54 PM | much better now | |
| Lisa Tolliver | 11/21/2002 | 9:49:13 PM | I think I can work with this for now. I'll try to see if I can get it and I'll get back to you. | |
| Paulette Mangold | 11/21/2002 | 9:49:28 PM | thank you very much | |
| Paulette Mangold | 11/21/2002 | 9:49:38 PM | now I just have to apply it | |
| Lisa Tolliver | 11/21/2002 | 9:49:41 PM | I understand what arrays are, I just don't understand the script that goes with them and with displaying what I want | |
| Haomin Wang | 11/21/2002 | 9:50:26 PM | you may need to refer to tonight's discussion scripts | |
| Haomin Wang | 11/21/2002 | 9:50:44 PM | I'll send it to you | |
| Lisa Tolliver | 11/21/2002 | 9:50:47 PM | I just thought there'd be an easy line or 2 or 3 or whatever to type in the script to find out the largest 3 and smallest 3 even if I didn't know there were 50 elements in my table | |
| Paulette Mangold | 11/21/2002 | 9:51:09 PM | [Private] I am saving the chat for future reference | |
| Lisa Tolliver | 11/21/2002 | 9:51:19 PM | Ok, I'll save it also, in case someone loses it . | |
| Lisa Tolliver | 11/21/2002 | 9:51:22 PM | Thanks for your help! | |
| Haomin Wang | 11/21/2002 | 9:51:25 PM | You can use MAX and MIN to find the largest and smallest, but one of each | |
| Paulette Mangold | 11/21/2002 | 9:51:38 PM | [Private] sorry cliff | |
| Lisa Tolliver | 11/21/2002 | 9:51:39 PM | not 3? | |
| Haomin Wang | 11/21/2002 | 9:51:50 PM | not even 2 | |
| Lisa Tolliver | 11/21/2002 | 9:52:07 PM | ohhh, well, that's been my question. That's what I've been trying to do! | |
| Haomin Wang | 11/21/2002 | 9:52:13 PM | unless there are two with the same value | |
| Lisa Tolliver | 11/21/2002 | 9:52:18 PM | ok | |
| Lisa Tolliver | 11/21/2002 | 9:52:33 PM | is next semester going to be a nightmare? | |
| Lisa Tolliver | 11/21/2002 | 9:52:44 PM | or worse? | |
| Haomin Wang | 11/21/2002 | 9:52:49 PM | daymare as well | |
| Lisa Tolliver | 11/21/2002 | 9:53:00 PM | thanks for the encouragement! | |
| Cliff De Long | 11/21/2002 | 9:53:05 PM | sounds heavenly (not) | |
| Haomin Wang | 11/21/2002 | 9:53:12 PM | because you may keep thinking of your program during the day as well | |
| Lisa Tolliver | 11/21/2002 | 9:53:29 PM | I am already having daymares!! | |
| Paulette Mangold | 11/21/2002 | 9:53:34 PM | I already try to program in my sleep and they still don't work | |
| Lisa Tolliver | 11/21/2002 | 9:53:35 PM | and not sleeping at night!! | |
| Haomin Wang | 11/21/2002 | 9:54:04 PM | I can have programming dreams sometimes and get good ideas in dreams | |
| Lisa Tolliver | 11/21/2002 | 9:54:06 PM | I thought this was an introductory class?? :) | |
| Haomin Wang | 11/21/2002 | 9:54:39 PM | It is. We haven't reached the professional level yet | |
| Paulette Mangold | 11/21/2002 | 9:54:43 PM | I wish | |
| Lisa Tolliver | 11/21/2002 | 9:55:03 PM | Please tell me we won't meet that level next semester either. | |
| Haomin Wang | 11/21/2002 | 9:55:25 PM | no. You'll need more than a degree program for that | |
| Lisa Tolliver | 11/21/2002 | 9:55:38 PM | good!!!!!!!!! | |
| Lisa Tolliver | 11/21/2002 | 9:56:04 PM | ok, well I'm going to bed! | |
| Haomin Wang | 11/21/2002 | 9:56:09 PM | Those undergraduates in compugter science are not necessarily professionals when they graduate | |
| Paulette Mangold | 11/21/2002 | 9:56:17 PM | I am going to sign off and hopefully have those good dreams. | |
| Lisa Tolliver | 11/21/2002 | 9:56:22 PM | Thanks for all your help! | |
| Paulette Mangold | 11/21/2002 | 9:56:30 PM | yes thank you very much | |
| Haomin Wang | 11/21/2002 | 9:56:31 PM | depending on how much they really know and can do | |
| Haomin Wang | 11/21/2002 | 9:56:48 PM | OK. Good night now | |
| Lisa Tolliver | 11/21/2002 | 9:56:49 PM | And where are the "professional level courses?" | |
| Haomin Wang | 11/21/2002 | 9:57:08 PM | No courses for professionals | |
| Lisa Tolliver | 11/21/2002 | 9:57:28 PM | training? | |
| Haomin Wang | 11/21/2002 | 9:57:35 PM | professionals come into being through experiences | |
| Lisa Tolliver | 11/21/2002 | 9:58:21 PM | I wish I could have a small enough experience to get me through this year! | |
| Cliff De Long | 11/21/2002 | 9:58:25 PM | practice makes faster - not perfect... | |
| Haomin Wang | 11/21/2002 | 9:58:30 PM | If one has only book knowledge, with limited experience, one cannot claim to be a professional | |
| Lisa Tolliver | 11/21/2002 | 9:58:59 PM | good night. | |
| Haomin Wang | 11/21/2002 | 9:59:23 PM | bye now | |
| Haomin Wang | 11/21/2002 | 9:59:38 PM | Cliff: you have questions, right? | |
| Cliff De Long | 11/21/2002 | 9:59:53 PM | So, can I just throw a little access database up in C:\Program Files\Apache Group\Tomcat 4.1\webapps\examples\jsp | |
| Haomin Wang | 11/21/2002 | 10:00:17 PM | That'll be a very bad idea | |
| Cliff De Long | 11/21/2002 | 10:00:25 PM | why? | |
| Haomin Wang | 11/21/2002 | 10:00:47 PM | since that's the directory for web scripts and you can even place HTML pages there | |
| Cliff De Long | 11/21/2002 | 10:01:07 PM | Where should I put it then? | |
| Haomin Wang | 11/21/2002 | 10:01:24 PM | database is usually placed in a directory that people would have little clue to | |
| Haomin Wang | 11/21/2002 | 10:01:53 PM | you can create a directory on your C drive or D drive and place it there | |
| Cliff De Long | 11/21/2002 | 10:02:12 PM | OK, once it is there | |
| Haomin Wang | 11/21/2002 | 10:02:26 PM | when you use Access, the default folder for databases is "My Documents" | |
| Haomin Wang | 11/21/2002 | 10:02:49 PM | for our course, whichever directory is fine | |
| Cliff De Long | 11/21/2002 | 10:03:07 PM | right, but I want to transfer the file from a workstation that has access to a server that doesn't... | |
| Haomin Wang | 11/21/2002 | 10:03:16 PM | in real use, the database directory is one that is out of web access range | |
| Cliff De Long | 11/21/2002 | 10:03:55 PM | right, My SQL 7 server is on a different box from the WebServer that accesses it | |
| Cliff De Long | 11/21/2002 | 10:04:08 PM | via ODBC | |
| Haomin Wang | 11/21/2002 | 10:04:17 PM | you can move a database across different computers, what specifies the path is the DSN | |
| Cliff De Long | 11/21/2002 | 10:04:57 PM | again, right - given that the DSN and ODBC tags point to the correct database | |
| Lisa Tolliver | 11/21/2002 | 10:04:58 PM | [Private] Cliff, I'm going to bed, but wanted to tell you thanks for being so patient through my questions. | |
| Cliff De Long | 11/21/2002 | 10:05:17 PM | [Private to Lisa Tolliver] Good night girl - sleep well | |
| Haomin Wang | 11/21/2002 | 10:05:30 PM | then locations don't matter, if DSN is set | |
| Cliff De Long | 11/21/2002 | 10:05:47 PM | Write a JSP script to create a table that stores information of students in a class you teach. We'll use the student information stored in this table in the next two weeks as a base to check student logins, generate a quiz from the database (on US states) for them to take, and store student performance records. So, design the students table accordingly. Email me the screen shots of your table structure, like the one we saw in this week's lesson notes, but yours doesn't have to mirror this. | |
| Cliff De Long | 11/21/2002 | 10:06:32 PM | again, right - I use a central access database that multiple workstations access in order to schedule videoconferences | |
| Haomin Wang | 11/21/2002 | 10:07:16 PM | Access database won't allow any external access | |
| Cliff De Long | 11/21/2002 | 10:07:18 PM | so, in your example, you gave an image of an access database, I'm confused that it would be jsp accessible by field name | |
| Haomin Wang | 11/21/2002 | 10:07:40 PM | You can place both your scripts and Access database in the same site | |
| Cliff De Long | 11/21/2002 | 10:07:49 PM | sure, as long as the drive is mapped, it appears local | |
| Haomin Wang | 11/21/2002 | 10:08:25 PM | It's not the drive; it's the site | |
| Cliff De Long | 11/21/2002 | 10:09:26 PM | I'll try it - will you be around this weekend? | |
| Haomin Wang | 11/21/2002 | 10:09:30 PM | a field name can be in any database. It has nothing to do with DSN | |
| Haomin Wang | 11/21/2002 | 10:10:01 PM | I'll be in Saturday, and will be out most of Sunday | |
| Haomin Wang | 11/21/2002 | 10:10:30 PM | I'll check emails Saturday noon | |
| Cliff De Long | 11/21/2002 | 10:11:36 PM | OK - I get it now, I was confusing MySQL with MSAccess | |
| Cliff De Long | 11/21/2002 | 10:12:28 PM | just set up the ODBC tag to point at the *.mdb file, and the JSP script should be able to modify the actual database... | |
| Haomin Wang | 11/21/2002 | 10:12:53 PM | I'd suggest you stick with Access for a while if you can. Tackle MySQL only when you have enough of Access or Access is not available. MySQL requires you to write lots of text commands | |
| Cliff De Long | 11/21/2002 | 10:13:13 PM | Data Source Name = pathname/*.mdb | |
| Haomin Wang | 11/21/2002 | 10:13:37 PM | Actually, it's not JSP that's modifying database, but SQL statements | |
| Cliff De Long | 11/21/2002 | 10:13:52 PM | Structured Query Language | |
| Haomin Wang | 11/21/2002 | 10:14:04 PM | SQL statments can run from most programming languages as long as you have access to a database | |
| Haomin Wang | 11/21/2002 | 10:14:30 PM | right | |
| Cliff De Long | 11/21/2002 | 10:14:37 PM | It just got a lot easier - good night and have a good weekend! :) | |
| Haomin Wang | 11/21/2002 | 10:14:44 PM | OK | |
| Haomin Wang | 11/21/2002 | 10:14:56 PM | have a good one! |