Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data fetching using collection in java servlet

 
Amit Jadli
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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]
 
Ahmed Bin S
Ranch Hand
Posts: 372
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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

 
Dave Tolls
Ranch Hand
Posts: 1906
14
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
ok..but then how could i get session object.
 
Dave Tolls
Ranch Hand
Posts: 1906
14
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic