Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I coded this, which is working but I think there is a better way to do this.. I have a form where the user can check from checkboxes. For each checkbox I have multiple info that I want to send to my servlet, so I thought to create manually a JSON...

<input name="warehouse" 
       value="{ 'version':'<%=b.getVersion()%>', 
                'product':'<%=b.getProduct()%>', 
                'productionDate':'<%=b.getProductionDate()%>', 
                'order':'<%=b.getOrder()%>' 
               }"  
       type="checkbox">

Then in my servlet, I read the checkboxes...

 String[] product = request.getParameterValues("warehouse"); 

I replace the " with '

product.replace("'","\""); 

and then I convert every String in JSON by:

ObjectMapper mapper = new ObjectMapper();
Box box = mapper.readValue(product, Box.class);

Is there a better way than the above to send the all these info to my servlet?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.