• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
 
Bartender
Posts: 9491
184
  • 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
Bartender
Posts: 9491
184
  • 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!