Feeds

Streamline your search with Yahoo! Web Services and AJAX

Google - not the only fruit

  • alert
  • submit to reddit

SANS - Survey on application security programs

The XML response returned by the Contextual Web Search service conforms to the XML Schema http://search.yahooapis.com/WebSearchService/V1/WebSearchResponse.xsd. In the input.jsp add a form containing fields for application ID, query, results, and context. The form may be submitted using GET or POST, but to use a context with many search terms use the POST method.

Send an AJAX request

To send an AJAX request we shall use a proxy servlet that routes the XMLHttpRequest from the browser to the Yahoo! Web Service. If an XMLHttpRequest is sent without a proxy servlet the XMLHttpRequest does not get sent and an error, such as the one below, is generated.

Error: uncaught exception: Permission denied to call method XMLHttpRequest.open

A proxy servlet may be developed or the HTTP proxy servlet may be used. Download httpProxyPackage.jar. Add the proxy servlet JAR file to the Libraries of the WebSearchWebService project. To the web.xml file add <servlet/> and <servlet-mapping/> elements for the proxy servlet.

<servlet>
        <servlet-name>HttpProxy</servlet-name>
        <servlet-class>com.jsos.httpproxy.HttpProxyServlet</servlet-class>
        <init-param>
            <param-name>host</param-name>
            <param-value>http://search.yahooapis.com/WebSearchService/V1/contextSearch</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>HttpProxy</servlet-name>
        <url-pattern>/servlet/yahoo</url-pattern>
    </servlet-mapping>

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 a XMLHttpRequest object
  3. Open a connection with the web service URL using the open() method of the XMLHttpRequest object
  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

In the input.jsp, to the input element of type button add a onclick event handler to invoke a JavaScript function displaySearchResults(). In the displaySearchResults function create an XMLHttpRequest object. XMLHttpRequest is supported as a native object in some browsers such as Netscape 6 or later and Internet Explorer 7 and as an ActiveXObject in other browsers such as IE 6.

Specify the proxy servlet URL to which an AJAX request is to be sent. Obtain the values for query, results and context request parameters from the input form. Open an XMLHttpRequest request using the open() method. Register a callback function that is to be invoked when the request state changes using the onreadystatechange property of the XMLHttpRequest object. Send the XMLHttpRequest request using the send() method. In the callback function check if the request is complete and invoke the JavaScript function processResponse() to update the web page with the Web Service response. The complete input.jsp is available in this zipped folder.

Integrated JavaScript editor

JDeveloper 11g includes an integrated JavaScript editor for creating JavaScript. In the previous section we added the JavaScript directly to the JSP, but the JavaScript may also be created in a separate .js file and the .js file added to the JSP using the <script/> tag. Create a JavaScript file by selecting File>New and in the New Gallery window Web Tier>HTML>JavaScript File. Copy the JavaScript from the input.jsp JSP to the JavaScript file and delete the JavaScript from the JSP.

3 Big data security analytics techniques

More from The Register

next story
Ubuntu 14.04 LTS: Great changes, but sssh don't mention the...
Why HELLO Amazon! You weren't here last time
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Next Windows obsolescence panic is 450 days from … NOW!
The clock is ticking louder for Windows Server 2003 R2 users
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
OpenBSD founder wants to bin buggy OpenSSL library, launches fork
One Heartbleed vuln was too many for Theo de Raadt
Got Windows 8.1 Update yet? Get ready for YET ANOTHER ONE – rumor
Leaker claims big release due this fall as Microsoft herds us into the CLOUD
Batten down the hatches, Ubuntu 14.04 LTS due in TWO DAYS
Admins dab straining server brows in advance of Trusty Tahr's long-term support landing
Red Hat to ship RHEL 7 release candidate with a taste of container tech
Grab 'near-final' version of next Enterprise Linux next week
Apple inaugurates free OS X beta program for world+dog
Prerelease software now open to anyone, not just developers – as long as you keep quiet
prev story

Whitepapers

Mobile application security study
Download this report to see the alarming realities regarding the sheer number of applications vulnerable to attack, as well as the most common and easily addressable vulnerability errors.
3 Big data security analytics techniques
Applying these Big Data security analytics techniques can help you make your business safer by detecting attacks early, before significant damage is done.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Securing web applications made simple and scalable
In this whitepaper learn how automated security testing can provide a simple and scalable way to protect your web applications.
Combat fraud and increase customer satisfaction
Based on their experience using HP ArcSight Enterprise Security Manager for IT security operations, Finansbank moved to HP ArcSight ESM for fraud management.