DataSet is a regular POST parameter, so get it the regular way.
DataSet is a regular POST parameter, so get it the regular way. Then use a JSON library like Jackson or gson to transform the JSON to an object. You'll need to define the structure as a class, however.So, if you have a DataSet class that maps exactly to the json you sent, you can fill it with (Jackson): ObjectMapper mapper = new ObjectMapper(); DataSet object = mapper.
ReadValue(dataSet, DataSet. Class); Then if you want to send some JSON ase response, either convert the response data and write it to the response.getWriter(), or if the library allows this, write the output directly to the writer. Jackson for example has writeValue(writer, object).
So in a servlet: ObjectMapper mapper = new ObjectMapper(); mapper. WriteValue(response.getWriter(), yourData); response. SetContentType("application/json").
Tahnku for help. But I update my question! – EM8H Nov 9 '10 at 7:28 @EM8H see updated – Bozho Nov 9 '10 at 7:40 it's work!
Tahnk you so much! – EM8H Nov 9 '10 at 9:27.
You can try this example for getting it right :- first pass name and age to onclick event through getUserDetails() method in js file from jsp then function getUserDetails() { var name = document. GetElementById('name'); var age = document. GetElementById('age'); // alert("hi " + name.
Value); $. GetJSON("../webresources/myresource", { name: name. Value, age: age.
Value }, function(json) { alert("name is= "+json. Name+ " and age is ="+json. Age); }); } and in servlet it should be like below :- public class MyResource { @GET @Produces("application/json; charset=UTF-8") public Response getIt( @QueryParam("name") String name, @QueryParam("age") String age) { Person person = new Person(); person.
SetName(name); person. SetAge(Integer. ParseInt(age)); // Person persons = personService.
FindPerson(person); String temp1 = person.getName(); int temp = person.getAge(); String temp2 = Integer. ToString(temp); StringBuffer buffer = new StringBuffer(); buffer. Append(" { 'name':'"); buffer.
Append(temp1); buffer. Append(" ','age': "); buffer. Append(temp2); buffer.
Append(" } "); String json = buffer.toString(); // for example constructed string looks like // String json = "{'name':'ravi','age':21}"; return Response. Ok(json, MediaType. APPLICATION_JSON).build(); }.
Use request.getParameterMap() and display all the request parameters. You may find your desired parameter there.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.