Javascript to call jsp, return JSON

Posted on 2012-08-19
Last Modified: 2012-08-24
Hi there:

I am trying to create a dynamic web page which has 1 dropdown with a few options, one submit button and some place for an image.
I have another application running on a server that I want to execute to return a JSON object to the webpage - the JSON will have the URL of the image that needs to be displayed.

I want help with 2 things:
a. Something on the client that will invoke a JSP or something on the server that will return the JSON
b. What are my options for serverside scripting? My app is deployed on Websphere.

Attached is sample code from the html
Question by:mightyestme
    LVL 75

    Accepted Solution

    You need Ajax - I also suggest jquery
    Million of good examples on the web

    I  now on my iPhone so not easy to see the source of your code but something like
      $("#sel").on("change",function() {
        $.get("somephp",function(data) {

    Author Comment

    I am new to Ajax - can I return a JSON from my servlet and the javascript will be able to extract parameters I want? Or should I be returning only the attributes I want to javascript to have access to?
    LVL 75

    Expert Comment

    by:Michel Plungjan
    If you return
    {"url":"image.gif"} the code I gave should work

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now