Results 1 to 5 of 5
- 07-12-2011, 03:03 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 4
- Rep Power
- 0
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!
- 07-13-2011, 09:47 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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).
- 07-13-2011, 10:02 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 4
- Rep Power
- 0
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?
- 07-13-2011, 10:09 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Store the whole user object, since there will possibly be other useful stuff in there.
So:
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.Java Code:session.setAttribute("user", user);
- 07-13-2011, 04:22 PM #5
Member
- Join Date
- Jul 2011
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
how to send a link through action class in struts
By Kadiyala in forum New To JavaReplies: 0Last Post: 02-17-2011, 07:44 AM -
send email may include, ONLY a whole web page at the place of text below, by refering
By lse123 in forum NetworkingReplies: 0Last Post: 08-06-2010, 05:40 PM -
Struts new page on .do link
By chizbox in forum Web FrameworksReplies: 0Last Post: 06-04-2010, 11:14 AM -
Need help in struts login page
By vinothkumarrvk in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-19-2010, 10:06 AM -
To send email of page present Web from a Jsp
By Marcus in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 06-09-2007, 04:08 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks