Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

how to convert sql data to json object in servlet  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, firstly i'm sorry about my bad language,  I made a servlet that reads data from db now i want to convert this sql data to json but when i try to create json object i'm getting this error 'JsonObject is abstract; cannot be instantiated' now how can i convert data coming from database to json file and how can i read it help me out !  here my servlet
 
Saloon Keeper
Posts: 9121
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mustafa, welcome to CodeRanch!

I suggest you use JAX-B with a JSON processor such as Jackson. If you combine this with an MVC framework such as Spring or Jersey, you can just return plain objects that will automatically get serialized to JSON for you.

Please don't output HTML directly from your servlet or controllers. Use a templating language like JSP or Thymeleaf to return HTML pages from your web application.
 
mustafa demir
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did it thank you so much i add json jar file then i've created a json object and it's done and i'm gonna use angularjs for output  thanks again
 
Stephan van Hulst
Saloon Keeper
Posts: 9121
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy you sorted it out :)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!