To add a JAR file to the project
select Tools>Project Properties. In the Project Properties window select
Libraries and add the JAR file with Add JAR/Directory button. Click on
OK in Project Properties window as shown in Fig. 10.14.
1 HTTP Proxy Servlet- http://www.servletsuite.com/servlets/httpproxy.htm
10.7 Sending an Ajax Request with Yahoo Search Web Services 211
Fig. 10.14 Adding Proxy Servlet JAR File to Project Libraries
To the web.xml file add
and
elements for the proxy servlet following the description
element.
HttpProxy
class>com.jsos.httpproxy.HttpProxyServletet-class>
host
http://search.yahooapis.com/WebSearchServi
ce/V1/contextSearch
HttpProxy
/servlet/yahoo
The procedure to send an Ajax request is as follows.
1. Initiate an Ajax request from an HTML event such as a button click.
2. Create an XMLHttpRequest object.
3. Open a connection with the Web Service URL using the open()
method of the XMLHttpRequest object.
212 10 Web Search with Ajax
4. Register a callback function to be invoked when the Ajax request is
complete.
5. Send the Ajax request with the send() method.
6. Update the web page with the Web Service response.
Pages:
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184