Javascript to call jsp, return JSON

Posted on 2012-08-19
Medium Priority
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
  • 2
LVL 75

Accepted Solution

Michel Plungjan earned 1500 total points
ID: 38309799
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

ID: 38310531
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
ID: 38310715
If you return
{"url":"image.gif"} the code I gave should work

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

840 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