Web programmingUnits WEB1P and WEB2P |
It is crucial to your development as a web programmer that you actually write some web programs! The following are a selection of graduated exercises to guide your practice. You don't have to do all of them (though the more you do the better). You don't have to write the precise program described here - any one with similar functionality will do. If you want to progressively develop your own webapp then by all means do so.
Timeframe | Exercise | You could also do the exercises from Basham chapters |
---|---|---|
Session 0 Before the unit starts / in the very early stages of it |
|
1 |
Sessions 1-3 While learning about servlets |
The aim is to familiarise yourself with writing and running simple servlets.
If you want to substitute your own application for the one suggested here, that would be fine. Hints
|
2, 3, 4 |
Sessions 2-4 While learning about servlets |
The aim is familiarise yourself with MVC and constructing web applications in an MVC style. Modify each servlet you wrote above so that instead of displaying its output itself, it calls a JSP to do it for it. To help you do this, look at the Hint: Pass the data read from the log file as a |
5, 6, 7, 8 |
Develop a web application (or extend an existing one) so that it stores information in a session variable. Use the session variable in the JSP output page. |
6, 11 | |
Develop a web application (or extend an existing one) so that it uses a filter. | 13 | |
Develop a web application that implements user authentication to restrict access to part of it. Use a filter to check access to all restricted parts. Have the filter redirect to a login page if the user in not logged in. Once a user has logged in successfully, record their identity in a session variable that the filter checks to see whether the user is logged in or not. Initially, either hard-code the users/passwords into your code or read them from a file. Later, convert your application to look up users and passwords in a database. | 12 | |
Sessions 7-8 While learning about JDBC and databases |
Develop a web application (or extend an existing one) that connects to a database. You could use either MySql (if you have it installed), or use the built-in Java database. The program could collect some simple data from the user (via a form) and store it in a database table. Using JPA/Hibernate is the easiest way to do this (since JPA will do all the JDBC calls for you). |
n/a |
If you want to get more sophisticated and do something more akin to a real-world application, try storing entities of more than one class in the database. Determine before you start whether the relationship between your entities is one-to-one, one-to-many, many-to-one, or many-to-many, and place attributes in your entity classes to indicate this. | n/a |
A separate series of exercises relating to JavaScript (sessions 5 and 6) can be found here.
Last updated by Prof Jim Briggs of the School of Computing at the University of Portsmouth |
||
The web programming units include some material that was formerly part of the WPRMP, WECPP, WPSSM and WEMAM units. |