Presentation is loading. Please wait.

Presentation is loading. Please wait.

And so on CGI programming Web Services Java Programs for the Web.

Similar presentations


Presentation on theme: "And so on CGI programming Web Services Java Programs for the Web."— Presentation transcript:

1 And so on CGI programming Web Services Java Programs for the Web

2 Other Languages used for Web Programming  CGI programs can be written in almost any language (C, Perl, …)  ASP.NET is the Microsoft approach  Java  Macromedia ColdFusion is a developer tool for web applications  XML is a language for defining data formats

3 CGI Programs  The Common Gateway Interface is a protocol for exchanging information between a browser and a program run by the web server.  Form data is often sent to a CGI program  CGI programs are generally restricted to a limited number of locations and users on the system

4 Environment Variables  CGI environment variables provide information about both the system the program is running on and the request that caused the program to be run  In Perl, environment variables are stored in a hash called %ENV

5 HTML Form Data  Two ways for a browser to send data to a CGI program  GET appends the data to the URL of the program  POST data is sent to the program as an input stream  This is more secure  In either case, the data encoded

6 URL Encoding  Spaces in the data are replaced by +  Alphanumeric characters are unchanged  Other characters are converted to a % followed by their hexadecimal ASCII codes  newline -> %0A  tab -> %09

7 Decoding Form Data read( STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split( /&/, $buffer); foreach ($pair (@pairs) { ($name, $value) = split( /=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/ pack("C", hex($1))/eg; $FORM{ $name} = $value; }

8 Security  You should always clean up form data before piping it to other programs  You should limit what programs can be run by the CGI program  You should limit where the CGI program can write data  Apache and suexec can be set up to limit who can run CGI programs

9 Web Services  Many programs accessible from the web are designed to communicate with other programs  A web service is a software system designed to support interoperable machine-to-machine interaction over a network  A number of protocols have been developed to facilitate this communication.  XML is often used to describe the data formats

10 Examples and Acronyms  SOAP - a protocol for exchanging XML- based messages  WSDL - Web Services Definition Language is used to describe the interfaces  UDDI - Universal Description, Discovery, and Integration provides a registry for services

11 Examples  Google Web API  http://www.google.com/apis/http://www.google.com/apis/  Java has classes to support web services

12 Sources  A web services Primer  http://webservices.xml.com/pub/a/ws/2001/0 4/04/webservices/ http://webservices.xml.com/pub/a/ws/2001/0 4/04/webservices/  Wikipedia  http://en.wikipedia.org/wiki/Web_services http://en.wikipedia.org/wiki/Web_services

13 Java for the Web  Java Applets are programs that run in a browser  Java provides a number of classes for implementing web services  Look at the Java Web Services Developer Pack (WDSP)  Look at The Java Web Services Tutorial by Lisa Friendly (both a book and an on-line tutorial

14 Java APIs  For XML  JAXP for processing XML Documents  JAXM for XML messaging  JAXR for XML registries  JAX-RPC for remote SOAP method calls  Web Applications  Java Servelets  JSP - Java Server Pages

15 Java Servelets  Like applets, servelets are java classes that can be run from the web.  The tomcat webserver manages these applications  class files and jsp files get copied into a directory that tomcat uses  All servelets implement the Servelet interface

16 Servelet Interface void init( ServeletConfig config) ServeletConfig getServeletConfig() String getServeletInfo() void service( ServeletRequest request, ServeletResponse response) void destroy()

17 Servelet Classes  There are two abstract Servelet classes you can extend to build your servelet  GenericServelet  HttpServelet - supports get and post  ServeletRequest and ServeletResponse are provided for transferring information to/from the servelet


Download ppt "And so on CGI programming Web Services Java Programs for the Web."

Similar presentations


Ads by Google