Results 1 to 5 of 5
  1. #1
    kalyana is offline Member
    Join Date
    Aug 2010
    Posts
    25
    Rep Power
    0

    Default Please help : handle database to jsp

    hi all.....
    i want handle some data from database to jsp , but i don't know which the best way to handle it .for example the data are : date ,time and light condition(on/off) .The data gonna be big data cause by the time data will increase .how to get/access the date into JSP ? use hash table ,vector or directly ...
    hope some one can show me ,how to do this...

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by kalyana View Post
    hi all.....
    i want handle some data from database to jsp , but i don't know which the best way to handle it .for example the data are : date ,time and light condition(on/off) .The data gonna be big data cause by the time data will increase .how to get/access the date into JSP ? use hash table ,vector or directly ...
    hope some one can show me ,how to do this...
    Tip #1: never let a jsp handle database communication. Use another Java class for that and let a servlet populate a, say, List, with the results and pass that to your jsp so it can concentrate on generating the html code so your results look nice when it arrives at the client.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    kalyana is offline Member
    Join Date
    Aug 2010
    Posts
    25
    Rep Power
    0

    Default

    thanks to Josah for your tips
    in the java class ,is there must use hashtable /vector to get the data first ?and then show to client the data on hashtable .i mind there must have temp place to handle data or any others way...

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by kalyana View Post
    thanks to Josah for your tips
    in the java class ,is there must use hashtable /vector to get the data first ?and then show to client the data on hashtable .i mind there must have temp place to handle data or any others way...
    Yep, make that other class/object collect the database from the db and store in a temporary List or Vector or whatever suits you fine. Let the jsp just display that data from the List or whatever.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Presumably each row of this data represents something, so create a class for that.
    The database code will populate a List of these (that's the usual thing).
    Your servelt will stick this list into the request, and then forward to your JSP.

    All your JSP does is print it out.

Similar Threads

  1. best way to handle db connection
    By uthpalaw in forum Advanced Java
    Replies: 11
    Last Post: 02-18-2011, 07:00 AM
  2. Access Database, Invalid Handle
    By JonJacobs in forum JDBC
    Replies: 1
    Last Post: 08-13-2010, 06:54 PM
  3. About File handle...
    By vaibhavspawar in forum New To Java
    Replies: 6
    Last Post: 07-19-2010, 08:28 AM
  4. Handle sound
    By varsamakos in forum AWT / Swing
    Replies: 4
    Last Post: 12-26-2009, 10:40 PM
  5. how to handle exceptions
    By paty in forum Advanced Java
    Replies: 2
    Last Post: 08-05-2007, 05:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •