tags:

views:

41

answers:

2

Hi, everyone,

I want to ask a question about the JSON and JSP. I have 2 JSP (JSP1 & JSP2) pages and 1 JSON format file.

Both of the JSP pages are pack into a .war file. The JSON file is stored in a web server(e.g. http://examp;e.com). And I have to do the following tasks:

1) Open the JSP1 (has a link)

2) When the user clicks the link, it will call the JSON file (http://examp;e.com)

3) Display the JSP2 and show the content of the JSON file

{ "class":
    {
        "number": 2,
        "student": 
        {
        "name": "Tom",
        "age": 1
        },
        "student": 
        {
        "name": "May",
        "age": 2
        }
    }
}  

I have the basic knowledge of the HTML and the JSP, but I don't know how to do this action. Should I use the in the JSP1, if yes, what object should I use in order to retrieve the JSON content? thank you very much.

+1  A: 

if it's only about displaying the JSON content available at some remote location into your page, you can probably use a hidden iframe linked to the location. keep the iframe invisible initially, and when the user clicks it, display it. you can use the "display" style property to toggle the visibility of the frame.

but remember, for this to work, the JSON text should be available as a plain text/html file. in other words, if the JSON object is present within the script tags, then you'll have to adopt a different approach.

anirvan
@anirvan-majumdar, thank you for your reply. I still have some questions as I don't know how to use the iframe. would you mind to give me some reference for it? thank you.
Questions
you should find this [http://www.w3schools.com/TAGS/tag_iframe.asp] useful. the attributes which should be of interest to you are - **src**, **height**, **width**
anirvan