Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CEN 4935 Independent Study Wireless Robot Controller Web Application 2009 Comprehensive Report March 19, 2009 Jess Summerhill 1. Introduction 1.1. Purpose The purpose of this independent study project is to show how a web application can interact with proprietary hardware; this project’s hardware is a small three wheeled robot. This is the era of the World Wide Web – universities and schools, as well as businesses have a very large investment in the internet today; it is no long sufficient to create an application that will work on a single computer. Today the demand is high to acquire the skills needed to make any application that can work on a single computer adaptable to be able to work across the internet. Many companies and universities have specific hardware requirements to meet the needs of their system; it is important to be able to assess the needs of a particular system and satisfy those needs with the proper implementation. 1.2. Scope The target audience of this document is intended to address the interest of computer science students, computer hobbyists, project managers, and application and web application engineers. This appeal is due to the several applications this project can have due to the different ways it can be applied. It is possible that most will not see the likeliness of the importance of a web application having the ability to interact with a robot; however the three wheeled robot is of no consequence, the type of hardware can be substituted for any robotic needs. A more general application is that the needs can be more than just robotic, but essentially any hardware. The motives may differ between audiences this project appeals to, but the result is the same: any user reading this document and applying the instructions to the robot and a server should be able to possess the basic knowledge of how software will interact over the internet with software working on a real-time device; this project addresses a three wheeled robot. Thus the goal of this project is to show how a web application will interact with hardware that is interfacing on the server that the web application is running. The web application will have the ability to interact with an embedded database as well as the robot. The information that is included in this report is the Software Requirements Specification, which is a document that gives a description of this system’s behavior, the Design Description, which specifies the architecture and application design of this project, the current implementation, and the current tests that have been ran. 2. Software Requirements Specification 2.1. Overall Description 2.1.1. Product perspective 2.1.1.1.Overall Design 2.1.1.1.1. Figure 2.1.1.1.1.1 displays the overall structure of this project design. It shows how users will interact with the robot over the internet. This figure shows that users will interact using their web browser to make interactions with the web application and the database; the web application will pass data to the Java Database and the robot driver software. Figure 2.1.1.1.1.1 Overall Program Design 2.1.1.2.Robot Program Design 2.1.1.2.1. Figure 2.1.2.1.1.1 displays how the web application will connect to the robot driver; it also displays the main programming components of the robot driver. The robot drive has two major components, the GUI application [1.3.2] and the robot logic. The GUI application is run on the server, while the robot logic is executed on the robot’s logic board, which is displayed in figure 2.1.2.1.2.1 this image can also be viewed on the website [1.4.14]. Data is transferred between the web application and the GUI application. The GUI application in turn transmits data to the robot using the Bluetooth device which is visible in Figure 3.1.2.2, and the robot logic software receives the robot the instructions from the Bluetooth device. Figure 2.1.2.1.1.1 Robot Program Design Figure 2.1.2.1.2.1 Robotics Controller 2.1.1.3.Web Application Design 2.1.1.3.1. Figure 2.1.3.1.1 shows what the web application consists of and data packets being sent to the robot driver. This diagram views the three main components of any Java web application: the deployment descriptor – which is an XML [1.3.11] file that uses the markup tags to describe to the Java web server software how the web application will be deployed. Figure 2.1.3.1.1 Web Application Program Design 2.1.1.4.Database Program Design 2.1.1.4.1. The diagram in figure 2.1.4.1.1 views the interaction with the database and the web application; the database will receive information form users on the internet. It will be sending updated information to the web application – informing the GUI [1.3.2] software for the robot driver of user information. Figure 2.1.4.1.1.1.1 Database Program Design 2.1.1.5.Server Interfaces 2.1.1.6. The server interfaces with the Linux OS [1.3.7], this in turn interacts with the HTTPD Apache web service. [1.4.6] 2.1.2. User Interfaces 2.1.2.1. Users will be able to interface with the robotic device over the internet, through their web browsers. 2.1.3. Hardware Interfaces 2.1.3.1. No additional hardware will be needed to interact with the robotic device. 2.1.4. Software Interfaces 2.1.4.1. User will need the Java runtime environment to interface with some of the web pages. Users will not need it to interface with the online application itself. 2.2. Product Functions 2.2.1. Wireless web cameras will be able to keep track of the robots movements. 2.2.2. The web application will be using a built-in database to get recorded information. 2.3. User Characteristics 2.3.1. Users with an interest in controlling a robot from their home computer. 2.4. Constraints 2.4.1. Users will only be able to control the robot within the allocated space of where the robot is physically located. 2.5. Assumptions and Dependencies 2.5.1. HTTPD Server 2.5.1.1. Apache HTTPD Server is software that provides a service to any computer that it is installed on – therefore any computer that has the ability to have this software installed on its OS [1.3.7] can have the ability to become a server. This software takes the request from users on the internet, interprets them into instructions that the OS [1.3.7] can understand, and provides a response. It was created by the Apache Software foundation. [1.4.7] 2.5.2. Tomcat 2.5.2.1. Apache Tomcat resembles some similarity to it predecessor Apache HTTPD server. The primary difference is that it is a Java web server. It handles deployment of a web application and translating JSP [1.3.6]. [1.4.5] 2.5.3. Glassfish 2.5.3.1. Sun Glassfish is an open source Java application server that was created by Java Sun instead of the Apache Software foundation. It has almost the same functionality as the Apache Tomcat, but the primary difference is manufacturer and user preference. This software is available to download and its source code is also available. [1.4.6] 2.5.4. 2.6. Specific Requirements 2.7. Required Materials 2.7.1. This project will implement various technologies, using various platforms. Thus, the implementation will need a hardware and a software solution. 2.7.2. Required Software 2.7.2.1. The software required to perform the implementation needs is: Java Enterprise Edition [1.4.3], Java Standard Edition [1.4.2], Apache Tomcat [1.4.5], Java Sun Glassfish [1.4.6], and Java Database [1.4.4] may as well be apart of this project. The server also needs Java RXTX software to interact with the Bluetooth device. [1.4.9] Once this software is installed, the user has to import all the java libraries used by this software package, and can start interacting with the robot’s Bluetooth device. 2.7.3. Required Hardware 2.7.3.1. The current hardware needed will be a wireless IP camera, similar to figure 3.1.2.1.1, as well as the robotic hardware needed in figure 3.1.2.1.2. Figure 3.1.2.1 Proposed IP Wireless Camera Figure 3.1.2.1.2 The IntelliBrain Robot with Bluetooth Device 2.7.4. Security Access Required security access will be needed to the physical address of the computer CSIDC, and remote access is required as well. 3. Software Design Description 3.1. Decomposition Description 3.1.1. Modular Overview Description 3.1.1.1.This will show and describe the overall design of the web application interfacing with other software modules. It will describe the overall concept of the web application software and the robotic software. 3.1.1.1.1. It is easily visible to see in the overall diagram [figure 3.1.1.1.1] on the design of this software. Users will visit the website and when visiting the correct webpage, they will be able to remotely control robotic device [2.14]. The robotic device will respond to user input from the internet by the user applying input from either his or her keyboard or his or her mouse. Figure 3.1.1.1.1.1 Overall Program Design 3.1.1.2. Modular Web Application Description 3.1.1.2.1. This will model and describe the overall design of the web application. The web application is responsible for retrieving data from the internet either by the Apache Tomcat Server [2.5] or the Java Sun Application Server [2.7]. It is the engineer, or hobbyist, or student, chooses which web application software he will use to build his or her web application. 3.1.1.2.1.1.The diagram [Figure 3.2.1.1.1] shows the overall structure of a web application. The web application is composed of three major parts: The java servlet, the java server pages, and the deployment descriptor. Figure 3.2.1.1.1.1 Web Application Program Design 3.1.1.3. Modular Robotic Application Description 3.1.1.3.1. This design will show the overall inner-workings of the robot application that will interface with the web application. It will also describe how the robot hardware will receive instructions from the java based robot software. 3.1.1.3.1.1.Figure 3.3.1.1.1 shows that it will be receiving data from the web application in the data form of simple integer values, and the robot driver translates this numeric data into bytes. These bytes are sent to the Bluetooth device that transmits the data wirelessly to the java software that is running on the robot [2.13] in figure 3.3.1.1.2. Figure 3.3.1.1.1 Robot Program Design Figure 3.3.1.1.1.2 The Robotic Device 3.1.2. Data Decomposition 3.1.2.1.Java Servlets Description 3.1.2.1.1. This will describe a java servlet is, and how this data is parsed and broken down into instructions the server [1.3.12] can understand. 3.1.2.1.1.1.A Java servlet is nothing more than java software – it is a java class file that responds the HTTP [1.3.12] request from the JSP [1.3.6] webpage. The frameworks for servlets are numerous; there are two that are installed on the server that this project will be running on, which was mentioned in section 1.3.2.1. Implementation of the servlet will be using the Apache Tomcat Server [2.5]. The Tomcat will compile the servlet into a java class file. The web application is composed of three components: The java servlet, the JSP file, and the deployment descriptor (web.xml) – which is an XML [1.3.11] file that tells Apache Ant [2.7] where all the file locations are on the server. Sections 3.2.1.1.1.1 – 3.2.1.1.1.3 describe code samples and the structure and what they do. 3.1.2.1.1.1.1. Appendix 6.1 gives an example of a java servlet. The custom servlet class will always extend the HTTPSerlvet class. This custom class is nothing more than receiving all the data from HTTPServlet class and adding more to it. The HTTPServlet class is the java class that receives the HTTP request [1.3.11] and performs the “get” function. The get function gets the webpage from the JSP webpage the sends the responds “Hello World”. 3.1.2.1.1.1.2. Appendix 6.2 displays an example of a JSP web page. The first two tags descript what type of document the web page is in – I will note that the details can get complicated – and the character format it is in as well. The rest of the tags are the standard HTML tags. The first tag tells the type of document the web page is, the head tag is like a header in a text document which contains the title tag which gives the title to the document, and then there is the body tag that defines the body of the web document. This contains the a tag that is labeled “h2” which gives the attribute to the text as a header – the difference between the header document and the h2 tag is one describes the format of the document and the other describes a modifier to the text within the tag. 3.1.2.1.1.1.3. Appendix 6.3 gives an example of a XML [1.3.11] document. XML is very much like HTML but the difference is the custom creation tags. Thus the only real standard in this document is the first tag. This tag in the simplest way of describing it is that it describes the type of document it is and what version of XML the document it is. There are a lot of other details in the header of the tag that are also somewhat complicated to describe and these details are not necessary to describe in this document, nor for the purposes of the project. The rest of the tags describe the contents of the way the web application is going to be deployed. These tags are custom, and thus there isn’t much of a standard for them. 3.1.2.2. Java Robot program Description 3.1.2.2.1. The description for the robotic software is comprised of three major components: the java compiler for the software on the server, the java robot compiler which takes java code and compiles it into instructions the robot will understand, and the Bluetooth hardware and the robot hardware. 3.1.2.2.1.1. This section will define Appendix 6.4 and how it relates to the project. This program’s main job is to acquire the serial port – which uses the RSR-232 standard [1.3.9] – and transfer data in bytes to the serial port. The serial port will receive this data and the Bluetooth device will transmit the signal. Thus the first part of the is using the ”gnu.io” package; this package uses native functions – which are functions that use the native OS [1.3.7], to perform operations in the program that use input and output hardware devices on the server [1.3.12]. This also implements the “java.io” package that allows for the software on the machine to interact with the user either by mouse input or keyboard input. The next block of java code displays java classes that contain functions that handle getting the serial port on com port 3 – this is nothing more than a communication port on channel 3 for the service. The function “establishConnection()” uses the java classes to establish a connection between the serial port and the java software program on the computer. There are a series of “try” and “catch” commands that tell the server to try to perform a specific operation, and if that operation cannot be preformed, then send a message to the user to let them know there is an error. 3.1.2.2.1.2.This section will define Appendix 6.5 for the java classes that will run on the robot’s controller device in figure 3.2.2.1.2.1. This java framework was designed Ridgesoft [2.14] and is proprietary software that uses java [2.2] to compile java source code to a file that will execute instructions on the robot controller. The proprietarty classes “com.ridgesoft.intellibrain” and “com.ridgesoft.robotics” contain specific classes and functions that interface with the robot controller board. The class ”Servo” tells the board to control either the right or the left wheel depending on how it’s defined in the program. The rest of the program tells the robot to move in a triangle fashion. Figure 3.2.2.1.2.1 Robotics Controller 3.2. Interface Description 3.2.1. User Graphic Interface 3.2.1.1.The simplicity of JSP [1.36] is that it is not necessary to have to build a GUI [1.3.2] for the user to interact with; it is designed to work inside the web browser of the users desktop. There is no need to have to build elaborate interfaces for the user – it is just a matter of web design – which is nothing more than using standard web browsing computer languages to design the web page to make it pleasing to the eye. Current construction of the web interface is still underway. 3.2.2. Administrator Graphic Interface 3.2.2.1.This interface is for the administrator that wants to check the status of the application to see if it is working correctly or not. This graphic interface will not be seen by the user, and therefore can be simple in nature. This application needs to be open and running at all times, and if the server which the application is running on is rebooted, then the application will need to be started again as well. Figure 4.2.1.1 is a sample of what the GUI [1.3.2] will look like. Figure 4.2.1.1 Graphic Interface for Administrator 3.3. Data Detailed Design 3.3.1. Modular Detail Data 3.3.1.1.Modular Web Application Detail 3.3.1.1.1. This section is going to briefly review section 3, and take the modules from that section and explain them in more detail. Section 3.1.1 covered the overall structure of the program and how the different pieces work together as a whole. The overview in this section is going to cover the details of the web application and the robot program modules. 3.3.1.1.1.1.A brief overview of the web application is it is build using the java programming language, using both the standard and if necessary the enterprise edition libraries [2.1 – 2.3]. The web application will also use Apache Tomcat [2.5] and Apache Ant [2.5]. The Tomcat is nothing more that a Java Servlet framework in which java web application can work. Apache Ant is the framework that is used to compile and build the web application. 3.3.1.1.2. The web application covered in section 3.1.2 is the software which the user will be interacting with the most. Section 3.1.2 described how the web application will work in my project; figure 5.1.1.2.1 displays the general composition of a Java web application. Figure 5.1.1.2.1 Java Web Application Structure 3.3.1.1.3. A Java web application is composed of 3 major parts: the Java Servlet, the JSPs [1.3.6], and the deployment descriptor. These are needed to make any Java web application. 3.3.1.1.3.1.Section 1.3.6 along with section 5.1.1.2.1 described what a JSP is – this module in figure 5.1.1.3.1.1 will graphically show the composition of a JSP. Appendix 6.2 shows an example JSP source file. The details of the JSP will be covered in section 5.2.1 Figure 5.1.1.3.1.1 Java Server Page Structure 3.3.1.2.Modular Robotic Application Detail 3.3.1.2.1. The module with graphically show the structure of the robot application and how the pieces interact with each other. 3.3.1.2.1.1.Section 3.2.1 briefly covers the structure of the robot application. This project will make a very simple application simply because it will never be seen by the user. Figure 4.2.1.1 shows the simplicity of the GUI [1.3.2]. Section 5.2.2 will cover the details of the robot composition. Figure 5.1.2.1.1.1 and figure 5.1.2.1.1.2 graphically shows the design. Figure 5.1.2.1.1.1 Robot Application Server End Figure 5.1.2.1.1.2 Robot Application Robot Hardware End Figure 5.1.2.1.1.3 Robot Hardware with Bluetooth Device Figure 5.1.2.1.1.4 Bluetooth Hardware with Cable Connects to Server 3.3.2. Data Entity Details 3.3.2.1. Java Web Application Detail 3.3.2.1.1. Section 5.1.1.1 covers the visual description of a Java web application; this section will discuss the details of the components of the application. 3.3.2.1.1.1.Section 5.1.1.3 began to discuss the three major components of a Java web application, but did not discuss these components in needed detail. 3.3.2.1.1.1.1. A Java Servlet is nothing more that a java file that is compiled by the JVM [1.3.14] using the Apache Tomcat [2.5] libraries. Appendix 6.1 is an example source of a java Servlet. The purpose of a Java Servlet is to respond to a JSP [1.3.6]. It can also update data on a server-side java application. This makes Java Servlets very useful in the academic and business worlds. This is true simply because while a Java Applet is a Java application that is run within the web browser, a Java Servlet is run on the server, receiving data from the JSP. The “doGet” function provided in Appendix 6.1, uses the HTTP request [1.3.13] from the JSP, to receive information from the given web page, and the Servlet can either process the information within the Servlet, or it can send this data to an application on the server its running on. 3.3.2.1.1.1.2. The deployment descriptor is an XML file [1.3.11] that the installed Apache Ant [2.6] uses to help properly deploy the web application to the correct configuration that is stored in the web.xml file. This file contains information on the name of the Servlet, name of the JSP associated with it, and how long the Servlet should wait before it sends back an error message. 3.3.2.1.1.1.3. Figure 5.1.1.3.1.1 shows the composition of a JSP; appendix 6.2 shows a sample source file. The way that this will interact in my project is that the JSP will send data to the Serlvet and the Servlet will send data the robot application, which will tell the robot to move and in which direction. The composition of the JSP is it has HTML [1.3.3] elements and nested inside the webpage is java syntax. These elements placed together create a JSP page. The purpose for a JSP is so that the Servlet does not have a series of print statements containing a lot of HTML tags and commands. A Java Servlet would not be able to compile and run the page if it had a lot of HTML syntax inside the Java String. Thus was created the JSP. The nested Java syntax within the JSP file sends data to the Java Servlet and updates it every time the request information is asked by the Servlet. 3.3.2.1.1.1.4. A quick overview is that these parts of the web application use Apache Tomcat, and Apache Ant. Ant uses the Deployment Descriptor to builds the web application into a working web application that responds to users. 3.3.2.2. Java Robot Program Detail 3.3.2.2.1. The robot program has two main parts: the server-side application and the robot-side application. The server-side application is for the server administration who desires the status of the application on the server. 3.3.2.2.1.1. Figure 4.2.1.1 displays an idea of how the GUI [1.3.2] is going to look very similar to actual deployment in development. The structure of this application is in figure 5.1.2.1.1.1; this shows how the individual pieces working together as a whole. 3.3.2.2.1.1.1. The server-side application uses the hardware visible in figure 5.1.2.1.1.4 – this cable and Bluetooth modem receive data from the application in bytes and send it to the robot in figure 5.1.2.1.1.3. Sample source code for this application is visible in Appendix 6.4, using this code to retrieve the serial port from the server, this application will continuously send data to the robot waiting to receive data and respond accordingly. This project will use the Servlet to send data to the robot application, and the robot application in turn will take the data sent from the Servlet and convert that data from integers to bytes, and then connect to the server’s serial port, which in turn gets transmitted by the cable and the Bluetooth modem in figure 5.1.2.1.1.4. 3.3.2.2.2. The robot-side application has a completely different structure than the server-side application; figure 5.1.2.1.1.2 shows how this structure works. The figure 5.2.2.2.1 displays the cable that connect to the robot in figure 5.1.2.1.1.3; this cable receives the data in bytes and sends it to the robot board in figure 3.2.2.1.2.1. However, this program is not compiled on the robot; it is compiled using the Ridgesoft RoboJDE [2.9] which is visible in figure 5.2.2.2.2. This software compiles the source which is visible in Appendix 6.5 and then is uploaded to the robot board in figure 3.2.2.1.2.1 via a serial cable. Both the server-side and the robot-side of the application communicate to each other via the Bluetooth modems. Figure 5.2.2.2.1 Robot-side Bluetooth Cable. Figure 5.2.2.2.2 Ridgesoft RoboJDE. 4. Implementation 4.1. The current implementation is still under test. The status of the requirements of the web application architecture is still being researched. The environment is installed and setup correctly, the test web page has been implemented. Updates will follow at a later time. 5. Test Documents 5.1. The test documentation has been implemented. The printed source is seen in the appendix. The equivalent of a “Hello World” web page has been produced and deployed. The web address this test page can be seen at http://csidc.fgcu.edu:8080/TestJSP/. 6. Conclusion 6.1. The end desired result is that the robot should react to users controlling it from the internet. The current status of the project is that it is still in test. Once the required research is gathered and implemented, the rest of the project should be implemented rather quickly. A safe assumption is ordering the required hardware needed for the completion of the project. This will evolve acquiring two IP cameras, and a wireless access point. All the necessary requirements outside of this have been acquired and achieved from the previous project. 7. Definitions, Acronyms, Abbreviations 7.1.1. DBMS. Database Management System – “It is computer software that manages databases.” [2.12] 7.1.2. GUI. Graph User Interface – it is a type of interface between the computer and the user that allows for a graphical representation of data. 7.1.3. HMTL. Hypertext Markup Language – it is a dominating markup language of the internet. It uses what are called "tags" to display text, links, heading, images, paragraphs and lists. This language is interpreted by the user's web browser and the server receiving the HTML request for the desired document. 7.1.4. JDBC. Java Database Connectivity – “The Java Database Connectivity (JDBC) API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases.” [2.4] 7.1.5. JDO. The Java Data Objects – “Standard interface-based Java model abstraction of persistence. Application programmers can use JDO technology to directly store Java domain model instances into the persistent store (database).” [2.4] 7.1.6. JSP. Java Server Pages – This markup language is similar to HTML, but the primary difference is that it allows for Java instructions to be inserted inside a custom tag. 7.1.7. OS. Operating System – This is computing software that allows for users to interact with the computers hardware and possibly other computers on a network. 7.1.8. RDBMS. Relational Database Management System – “It is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd. Most popular commercial and open source databases currently in use are based on the relational model.” [2.13] 7.1.9. RS-232. Recommended Standard 232 – “A standard for serial binary data signals connecting between a DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment).” [2.12] 7.1.10. SQL. Structured Query Language – It is a database computer language that allows interaction such as creation, modification, and querying of the database between application software and database architecture such as database objects. 7.1.11. XML. Extensible Markup Language – It is a computer scripting language very similar to HTML, but the main difference is that the web developers can custom design tags in this language to suit his or her needs. 7.1.12. Server – It is a computer that is designed and engineered to respond to HTTP [1.3.13] requests. This computer takes the HTTP request and responds with the requested web page. An example would be an HTML document [1.3.3]. Typically servers are used for businesses. 7.1.13. Hypertext Transfer Protocol – it is a procedure handles responds and requests between servers [1.3.13] and computer users at homes over the computer world wide network known as the World Wide Web. It was developed by the World Wide Web Consortium [2.15] and Tim Berners-Lee [2.16]. 7.1.14. JVM – the Java Virtual Machine – it is an internal engine within the java compiler that receives java byte code (it is data produced from the java compiler 8. References 8.1. Sun Microsystems Inc, Santa Clara, CA, 2008 http://java.sun.com/javase/6/docs/api/ 8.2. Sun Microsystems Inc, Santa Clara, CA, 2008 http://java.sun.com/javase/ 8.3. Sun Microsystems Inc, Santa Clara, CA, 2008 http://java.sun.com/javaee/ 1.1. Sun Microsystems Inc, Santa Clara, CA, 2008 http://java.sun.com/javase/technologies/database/ 1.2. The Apache Software Foundation, 1999-2009 http://tomcat.apache.org/ 1.3. The Apache Software Foundation, 1999-2009 http://ant.apache.org/ 1.4. Sun Microsystems Inc, Santa Clara, CA, 2008 https://glassfish.dev.java.net/ 1.5. The Apache Software Foundation, 2008 http://httpd.apache.org/ 1.6. RidgeSoft, Pleasanton, CA, 2009 http://www.ridgesoft.com/intellibrainbot/intellibrainbot.htm 1.7. Keane Jarvi, 1998-2006 http://users.frii.com/jarvi/rxtx/index.html 1.8. Wikimedia Foundation, January 27 2009, http://en.wikipedia.org/wiki/RDBMS 1.9. Wikimedia Foundation, January 28 2009, http://en.wikipedia.org/wiki/Database_management_system 1.10. Wikimedia Foundation, January 22 2009, http://en.wikipedia.org/wiki/RS-232 1.11. RidgeSoft, Pleasanton, CA, 2009 http://www.ridgesoft.com/intellibrain2/intellibrain2.htm 1.12. World Wide Web Consortium, 1998-2007, http://www.w3.org/Consortium/ 1.13. Tim Berners-Lee Information and Biography, 2009, http://www.w3.org/People/Berners-Lee/ 9. Appendix 9.1. An example java servlet: import java.io.*; import javax.servlet.http.*; import javax.servlet.*; public class TestServlet extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException PrintWriter out = res.getWriter(); out.println("Hello, World!"); out.close(); { } } 9.2. An example JSP web page: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Test JSP Page</title> </head> <body> <h2>Hello World! </h2> </body> </html> 9.3. An example deployment descriptor: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>TestServlet</servlet-name> <servlet-class>TestServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>TestServlet</servlet-name> <url-pattern>/TestServlet</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 9.4. An example Robot program running on the server: import gnu.io.*; import java.io.*; public class SerialConnectGUI { protected BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); protected byte[] buffer = new byte[64]; protected String messages[] = new String[14]; protected CommPortIdentifier portId; protected CommPort commPort; protected SerialPort serialPort; protected OutputStream outputStream; protected boolean dataflag; byte moveX, moveY; protected void establishConnection() { try { portId = CommPortIdentifier.getPortIdentifier("COM3"); System.out.println("Establishing connction....."); messages[0] = "\nEstablishing connction.....\n"; } catch ( NoSuchPortException noport) { System.out.println("Port not found: "+ noport); messages[0] = "Port not found: "+ noport+"\n"; } try { serialPort = (SerialPort) portId.open(this.getClass().getName(), 50); System.out.println("Port has been found."); messages[1] = "Port has been found.\n"; } catch (PortInUseException usedport ) { System.out.println(usedport); messages[1] = "" +usedport; } try { serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); System.out.println("Esablishing the transfer rate settings for COM3."); messages[3] = "Esablishing the transfer rate settings for COM3.\n"; } catch (UnsupportedCommOperationException nosupcom) { System.out.println(nosupcom); System.out.println("The tranfer rate could not be esblished on COM3."); messages[3] = "The tranfer rate could not be esblished on COM3.\n"; } try { outputStream = serialPort.getOutputStream(); messages[4] = "Establishing an output stream.... \n"; System.out.println("Establishing an output stream...."); getStreamOut(outputStream); } catch (IOException ioexc) { System.out.println("There is an input/output problem: " + ioexc); messages[4] = "There is an input/output problem: " + ioexc; } System.out.println(serialPort.getFlowControlMode()); messages[5] = "Establishing connection types: " + serialPort.getFlowControlMode()+"\n"; } 9.5. An example Robot program running on the robot hardware: import com.ridgesoft.robotics.*; import com.ridgesoft.intellibrain.*; public class MoveRoboTriangle { public static void main(String args[]) throws InterruptedException{ Servo leftwheel = IntelliBrain.getServo(1); Servo rightwheel = IntelliBrain.getServo(2); // Add your code here for (int i = 0; i < 3; i++) { leftwheel.setPosition(0); rightwheel.setPosition(100); Thread.sleep(5000); leftwheel.setPosition(100); rightwheel.setPosition(100); Thread.sleep(313); } leftwheel.off(); rightwheel.off(); } }