Results 1 to 5 of 5
  1. #1
    fabbero is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default Struts 1.3 how to send data from database to the jsp page!

    Hi everyone, and sorry if it isn't the right zone to explain my problem.

    I've completed a registration form , with all the personal data and it works!(successfuly save on the database)
    Then the LoginForm. I submit username and password, and it works too.
    But now there's my problem: i want to see the message welcome "user" in the other jsp pages, where user is his name saved in the db.

    (i 'm not allowed to use java code on the jsp)



    Now in my LoginAction class i m calling a method

    User user = daoFactory.userDAO().checkLogin(loginform.getUserN ame(),loginform.getPassword(),connection);

    where checklogin is a method with the query on the db, userName and password are the data that i submited!
    and it 'll return a object user with all the information i need.
    (i saw it on the debug!)

    But now i don t know how to pass this information on the jsp.
    I tried

    Welcome <bean:write name="LoginForm" property="userName" />

    but it works only with the informations i passed by keyboard
    I tried
    //a= loginform.setName(user.getFirstName()); and changed username with a but nothing:i had
    this error: No getter method for property

    Probably i miss something but i don t know what. Can someone say me how to pass the user information on the jsp?
    thank you!

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

    Default

    Store the user object in the session.
    Then the JSP page can access it from the session.
    This will also allow you to identify if someone has logged in successfully or not (if you get around to doing general security stuff).

  3. #3
    fabbero is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    Thank u for your answer Tolls but i 've not understood what u said sorry^^"

    i stored in session
    session.setAttribute("session", user); or session.setAttribute("session", user.getName()); if is the same..

    but how can the JSP page access it from the session??.


    my only tag is

    <bean:write name="LoginForm" property="userName" /> but i can t use session in property!

    Can you say me pls?

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

    Default

    Store the whole user object, since there will possibly be other useful stuff in there.
    So:
    Java Code:
    session.setAttribute("user", user);
    As for getting, the name will be "user", the property will be whatever the name of the property is in your User bean that you want to display, and the scope will session.

  5. #5
    fabbero is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    ok thank u very much. you're very kind :)

    i've finally solved it!

Similar Threads

  1. how to send a link through action class in struts
    By Kadiyala in forum New To Java
    Replies: 0
    Last Post: 02-17-2011, 07:44 AM
  2. Replies: 0
    Last Post: 08-06-2010, 05:40 PM
  3. Struts new page on .do link
    By chizbox in forum Web Frameworks
    Replies: 0
    Last Post: 06-04-2010, 11:14 AM
  4. Need help in struts login page
    By vinothkumarrvk in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-19-2010, 10:06 AM
  5. To send email of page present Web from a Jsp
    By Marcus in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-09-2007, 04:08 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
  •