java - display results in jsp by calling a servlet using jquery ajax? -


i want call servlet. servlet fetch data database , keeps in request. , result need t display in some.jsp using jstl tags.

$('#ownform #mybutton').click(function() {          $.ajax({             type: "get",             url: "./controller",             success: function(msg) {                 //todo             },             error: function(ob,errstr) {                 //todo              }         });          }); 

in servlet have below code:

//keep database returned list in request  request.setattribute("myresult", result); request.getrequestdispatcher("/web-inf/some.jsp").forward(request, response); 

please me how can achieve it?

ignore jsp. use flexjson serialize result directly result object json. print serialized result out stream in response.

something this:

response.setcontenttype("application/json"); response.setcharacterencoding("utf-8"); jsonserializer serializer = new jsonserializer(); serializer.exclude("*.class"); //reduce clutter in output see fit serializer.serialize(objecttoserialize, response.getwriter()); 

using jquery, parse json , act on result.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -