Raw Web Programming
You must complete this program with a partner. Once you have a pairing, e-mail the TAs. If you need help finding a partner, also e-mail the TAs. See the syllabus for details on team coding assignments. You will work in this team for the next few assignments.
This assignment asks you to write a web program. At this point in the course, the purpose of this assignment seems unclear. Once the assignment has been handed in, however, we’ll introduce an entirely new way of programming the web which is intimately linked with one of the fundamental ideas in programming languages. By completing this assignment now, you’ll be better prepared to appreciate this idea when we introduce it in class.
Though this assignment should not take you very long to program, we are giving you a lot of time because we know that not all of you are familiar with web programming and you may need to do some learning on your own. And, to lessen the likelihood of last-minute problems with your program’s execution, this project has an early “Hello, World!” hand-in in which you must demonstrate you have a web programming environment set up.
Choose Your Language
Unlike the other programming assignments in the course, in this one you will be able to use your choice of programming language. If you’re already familiar with web programming, choose a language that you’re comfortable with. If you’re not, the web is a font of meta-information, so you should have little trouble in finding resources about programming for it.
Your web program must run as:
- A CGI script. CGI stands for “Common Gateway Interface” and is the simplest web-programming protocol. You may run CGI programs on the department’s www-int server by creating a directory for yourself inside /pro/web/cgi-bin and putting your world-readable and -executable files there. We recommend using CGI if you have never programmed a web application before.
- A Java servlet. If you have used Java servlets before, perhaps in CS 32, 138, or 196-9, you may use them for this assignment. You will be responsible for starting and maintaining a Tomcat server instance for your servlet. Both traditional servlets and JSPs are acceptible.
- A PHP script. Finally, you may use PHP. Unlike the other options, you will have to host your application on your own machine, as the department’s web server does not have PHP enabled.
You will handin both the source of your web application and a URL where it is running.
“Hello, World!”
We’re encouraging you to get your web programming setup sorted out early on by requiring you to create and run a “hello, world!” web application. The application should show a web page with the text “hello, world!” and the current time and date.
We won’t require a formal handin for this. Instead, e-mail the TAs with the URL of your application and what language/environment you’re using. We must receive this e-mail by 2AM on September 22nd.
Program Requirements
You will write the authoring half of a simple blogging tool. (The publishing half that would complete the tool is outside the scope of this assignment.) Although this program is quite simple, it is representative of the core of much larger Web software (just as the interpreters we write in this course are themselves quite lean, but represent the core of large programming languages).
Weblogs (“blogs”) are web pages that consist of a list of posts ordered so that newer content is at the top. For our purposes, a post is a title, some body text, and a date that it was written. You can assume that the title and body are plain, ASCII-encoded text. In particular, this means that your software will need to escape HTML entities: typing “<b>” into a text field should not make any part of the post bold.
The main page of your web application should have:
- A list of posts, sorted correctly.
- A form for creating new posts, with a field for the title and a text area for the body.
Upon submmitting the form, the user should see a preview page that shows the post along with its date. The post is not shown on the main page until the user confirms it from the preview page, either through a link or a form button.
We do not require that you save posts to disk, but you may need to, depending on your choice of web application environment. We require that your web application pass this persistence test: a post added from one computer should be visible from the main page on an entirely different computer, if the web server has not been restarted. You do not need to worry about concurrent accesses (i.e. you need not lock any data files).
We have a demo that is available from inside the department. You may duplicate the demo’s design if you like, or you may come up with your own. Your functionality should match the demo’s, however.