• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

data fetching using collection in java servlet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am fresher in programming.i want to print the fetching data from table by using collection in servlet. so, can any one would like to help me.

this is my code ....i got error in this code in calling the service class.
Screenshot_1.png
[Thumbnail for Screenshot_1.png]
Screenshot_2.png
[Thumbnail for Screenshot_2.png]
 
Ranch Hand
Posts: 385
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Both images are of ViewController.
2) It is much easier for us if you copy and paste the code and enclose it in [code] tags than if you post screenshots.
3) Please don't just say you got an error, please provide what the error is.

Thanks.
 
Amit Jadli
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for suggesting me... Actually i have to manipulate data from database to webpage using collection in servlet following MVC pattern. It's my part of project. I done my coding on this but i gor compile time error. It's my viewservice coding


it's my controller class coding

 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what error is it you are getting?

Just a general comment on the code, it's not good practice to let the http stuff filter down into your service layer.
In other words, you should not b passing around the request and response. You should get the data you need out of it and pass that down, possibly as a model, and then either handle any exceptions thrown by the service, or handle the return value. The service shouldn't care that it is part of a web server.
 
Amit Jadli
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok..but then how could i get session object.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't.
You pass it into the method call.

Essentially the servlet gathers the data together that the service needs for its job.

ETA: Just re-read that, and when I say "you pass it into the method" I mean that you pass the username into the service method, not the session.
reply
    Bookmark Topic Watch Topic
  • New Topic