IMPLEMENTATION OF A GENERAL WEB API FOR GEOINFORMATICS Implementation of a General Web Application Program Interface for Geoinformatics Jan Pytel Department of Mapping and Cartography Faculty of Civil Engineering, CTU in Prague E-mail: pytel@fsv.cvut.cz Keywords: Java language, C++language, servlets, CGI, web applications Abstract C++ language was used for creating web applications at the department of Mapping and Car- tography for many years. Plenty of projects started to be very large-scale and complicated to maintain. Consequently, the traditional way of adding functionality to a Web Server which previously has been used (CGI programs) started being usefulness. I was looking for some solutions - particularly open source ones. I have tried many languages (solutions) and finally I chose the Java language and started writing servlets. Using the Java language (servlets) has significantly simplified the development of web applications. As a result, developing cycle was cut down. Because of Java JNI (Java Native Interface) it is still possible to use C++ libraries which we are using. The main goal of this article is to share my practical experiences with rewriting typical CGI web application and creating complex geoinformatic web application. Introduction The modern era brings new phenomenon: World Wide Web, a term frequently used (in- correctly) when referring to “The Internet”. It stands for the universe of hypertext servers (HTTP servers), more commonly called ”web servers”, which are the servers that serve web pages to web browsers. A plain www page (HTML document) is static, which means that a text file doesn’t change - for example: CV, research papers, etc. When someone would like create web pages that contain dynamic content a plain www pages are not sufficient: a solution is to create CGI programs with using languages like PHP, C++, Perl, etc. PHP or C++ languages were used for creating web applications at the department of Mapping and Cartography for many years, some examples are: � Internet access to the database of GPS observation via www. The project is written in C++ language: http://www.vugtk.cz/gpsdb � online transformation between ETRF and S-JTSK http://gama.fsv.cvut.cz/~kost/vypocty . Plenty of projects started to be very large-scale and complicated to maintain. Consequently, the traditional way of adding functionality to a Web Server which was used (CGI programs) has become unsustainable. I was looking for alternatives - particularly open source ones. I have tried many languages (solutions) and finally I chose the Java language and started Geinformatics FCE CTU 2006 44 http://www.vugtk.cz/gpsdb http://gama.fsv.cvut.cz/~kost/vypocty IMPLEMENTATION OF A GENERAL WEB API FOR GEOINFORMATICS writing servlets. This paper briefly introduces the servlet concept and explains how to create general web application program interface for geoinformatics. Common Gateway Interface - CGI The Common Gateway Interface (CGI) programs are “normal” programs running on the server side — input data for CGI programs are requests from a client (data sent by web browser - HTTP header with other information). Output from CGI program is sent back to the client (web browser). This concept means that client side does not need to take care which type of page is requested. Side dynamic www pages and static www pages are transparent - client sends a request with data and obtains www page. The CGI programs have to be placed in the special directory (usually /usr/lib/cgi-bin), the directory where system expects CGI programs. An example of dummy CGI program date (used script language bash) which returns current date in ISO 8601 format ’YEAR-MONTH-DAY’: #!/bin/bash echo ’Content-type: text/html’ echo echo ’’ echo ’’ echo ’
’ /bin/date -I echo ’’ echo ’’ echo ’