Results 1 to 3 of 3
  1. #1
    dojha00 is offline Member
    Join Date
    Mar 2012
    Location
    somewhere in between the codes
    Posts
    2
    Rep Power
    0

    Question Displaying user details in jsp

    Hey,
    I m developing an web application in which there is a link like "view profile" after clicking that user will redirect to another page and that page contains user detail which is fetched from database(db2). So is anyone can help me by telling me the way how to implement it..
    I have two ways to implement--
    1. store the detail in a class object and save it in session
    Problem:- I read many places that we should not store big objects in session.

    2.I can write database connection code on jsp page and can show the detail..
    Problem:- user can see the table details by editing page source code.

    Is there any other way which is secure and efficient??


    Sorry for asking such kind of noob question. I was not knowing that by editing page source, java codes will not be visible.
    a request to admin to delete this post..
    Last edited by dojha00; 03-30-2012 at 07:19 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default Re: Displaying user details in jsp

    If you're concerned about the amount of data loaded into the session (which is reasonable, especially if the data isn't needed throughout the site) then read the data in as they access the page.
    That is, have a servlet call your data layer (a DAO) to get an object that represents the profile. Stick that in the request (addAttribute), forward to the JSP which will then display the relevant bits.

    As for option (2), apart from never doing this in a JSP anyway as it's bad practice, it is not insecure at all. The code that does the database access would be Java code, which is executed on the server.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    dojha00 is offline Member
    Join Date
    Mar 2012
    Location
    somewhere in between the codes
    Posts
    2
    Rep Power
    0

    Default Re: Displaying user details in jsp

    Quote Originally Posted by Tolls View Post
    If you're concerned about the amount of data loaded into the session (which is reasonable, especially if the data isn't needed throughout the site) then read the data in as they access the page.
    That is, have a servlet call your data layer (a DAO) to get an object that represents the profile. Stick that in the request (addAttribute), forward to the JSP which will then display the relevant bits.

    As for option (2), apart from never doing this in a JSP anyway as it's bad practice, it is not insecure at all. The code that does the database access would be Java code, which is executed on the server.

    Really at some pages i used 1st method but at some places i also used second method..
    but thanks for telling me the difference and passing arguments using request object...
    since i m new to jsp so i m learning all these..
    Last edited by dojha00; 04-04-2012 at 08:31 AM.

Similar Threads

  1. Displaying a square based on user's input
    By luke in forum New To Java
    Replies: 15
    Last Post: 07-14-2012, 09:43 AM
  2. Loading and Displaying a user chosen image
    By forwardbias in forum AWT / Swing
    Replies: 9
    Last Post: 03-18-2012, 08:54 AM
  3. help with displaying calculation with user input
    By bamagirl31 in forum New To Java
    Replies: 18
    Last Post: 05-26-2011, 04:00 AM
  4. Displaying the right details of a resource taken from a JSP results page
    By rushhour in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-20-2011, 10:36 AM
  5. finding details in database using JSP and forwards user to a HTML page
    By sandraW in forum JavaServer Pages (JSP) and JSTL
    Replies: 7
    Last Post: 08-31-2010, 09:47 AM

Tags for this Thread

Posting Permissions

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