-
CGI and Java Servlets Web-Database Programming
[QUOTE]CGI or Common Gateway Interface is a means for providing server-side services over the web by dynamically producing HTML documents, other kinds of documents, or performing other computations in response to communication from the user. In this assignment, students who want to interface with the Oracle database using Oracle's Pro*C precompiled language will be using CGI.
Java Servlets are the Java solution for providing web-based services. They provide a very similar interface for interacting with client queries and providing server responses. As such, discussion of much of the input and output in terms of HTML will overlap. Students who plan to interface with Oracle using JDBC will be working with Java Servlets.
Both CGI and Java Servlets interact with the user through HTML forms. CGI programs reside in a special directory, or in our case, a special computer on the network (cgi-courses.stanford.edu), and provide service through a regular web server. Java Servlets are separate network object altogether, and you'll have to run a special Servlet program on a specific port on a Unix machine.
Retrieving Input from the User
Input to CGI and Servlet programs is passed to the program using web forms. Forms include text fields, radio buttons, check boxes, popup boxes, scroll tables, and the like.
Thus retrieving input is a two-step process: you must create an HTML document that provides forms to allow users to pass information to the server, and your CGI or Servlet program must have a means for parsing the input data and determining the action to take. This mechanism is provided for you in Java Servlets. For CGI, you can either code it yourself, find libraries on the internet that handle CGI input, or use the following example code
Forms
Forms are designated within an HTML document by the fill-out form tag:
<FORM METHOD = "POST" ACTION = "http://form.url.com/cgi-bin/cgiprogram"> ... Contents of the form ... </FORM> The URL given after ACTION is the URL of the CGI program (your program). The METHOD is the means of transferring data from the form to the CGI program. In this example, we have used the "POST" method, which is the recommended method. There is another method called "GET", but there are common problems associated with this method. Both will be discussed in the next section.
Within the form you may have anything except another form. The tags used to create user interface objects are INPUT, SELECT, and TEXTAREA.
The INPUT tag specifies a simple input interface:
<INPUT TYPE="text" NAME="thisinput" VALUE="default" SIZE=10 MAXLENGTH=20> <INPUT TYPE="checkbox" NAME="thisbox" VALUE="on" CHECKED> <INPUT TYPE="radio" NAME="radio1" VALUE="1"> <INPUT TYPE="submit" VALUE="done"> <INPUT TYPE="radio" NAME="radio1" VALUE="2" CHECKED> <INPUT TYPE="hidden" NAME="notvisible" VALUE="5">
Keywords: CGI,Common Gateway Interface , HTML documents, documents,user,language ,Java Servlets , Java solution ,HTML, CGI programs , web server,Unix machine,Servlet programs, text fields, radio buttons, check boxes, popup boxes, scroll tables
Last edited by sherlyk; 01-21-2013 at 06:52 AM.
-
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks