I wrote a jsp which request to the servlet and return a json to my jsp ,my problem is that I want to iterate on json and show it in my page ,but I do not know how to get my json in my javascript function . I do not want to use jquery ui an ajax . I want to write it in pure javascript and jsp . tnx for ur help.
            Asked
            
        
        
            Active
            
        
            Viewed 2,579 times
        
    0
            
            
        - 
                    http://stackoverflow.com/questions/9645647/return-json-from-servlet – Pravitha V Jul 20 '12 at 06:04
- 
                    http://stackoverflow.com/questions/6154845/returning-json-response-from-servlet-to-javascript-jsp-page – Pravitha V Jul 20 '12 at 06:04
2 Answers
0
            
            
        Try something like this,
var json = xmlHTTPRequest.responseText,
obj = JSON.parse(json);
alert(objJSON.result);
alert(objJSON.count);
 
    
    
        Nirmal
        
- 4,789
- 13
- 72
- 114
0
            Assuming you are already holding the JSON somewhere within your JSP, this examples shows how to access JSP content from a javascript function: JSP/JavaScript-Example. If my assumption is wrong, you maybe want to post your code for further suggestions.
- 
                    I know the best way is using ajax but I was told to do this without using ajax !! – Mina Jul 22 '12 at 07:13
- 
                    Assuming you are already holding the JSON somewhere within your JSP, this examples shows how to access JSP content from a javascript function: [JSP/JavaScript-Example](http://stackoverflow.com/questions/4803906/jsp-variable-accssing-in-javascript). If my assumption is wrong, you maybe want to post your code for further suggestions. – Ben-G Jul 23 '12 at 07:26
- 
                    Just changed the content of my answer, to the content of the comment. You may want to mark it as correct answer. – Ben-G Jul 31 '12 at 06:58
 
     
    