user2805663
user2805663

Reputation:

ideas on retrieving data from database struts 2 web app

I have a struts 2 web app where I have already a log in and register account page. When the user logs in he will be forwarded to a new page where I want to show his name same with register. After registration he will then be forwarded to a page that shows his name. I have no idea how to implement this method from login but I was able to make it in registration page by getting the name from the input text. My problem is: How do I get the data(name) from the database by just using the email in the login page? Another problem is: When I'm in the name page I want a button that when the users clicks the button I want to display all his available info.

registration

after registration when I click submit the next page will be

after registration

we can see here that the name is being displayed and when i click search all the data about john will be display in this page as well.

login

this is the log in page when i log in the next page will be

from login

but we can see here that the name is not displayed i'm out of idea on how to get data(name) from database just by using the email from the login same and then same sa from registration i want to display all data about john when the button search is clicked

UPDATE:

i was able to get the value of the data now from the database but i was just able to show it on console i cant a way to show it on jsp any ideas this is how it looks enter image description here

Upvotes: 1

Views: 920

Answers (2)

user2805663
user2805663

Reputation:

ANSWER ON UPDATE QUESTION:i just put these things on my jsp and it did something good

name:    <s:property value="user.getName()"></s:property>
email:   <s:property value="user.getEmail()"></s:property>
address: <s:property value="user.getAddress()"></s:property>
gender:  <s:property value="user.getGender()"></s:property>

Upvotes: 1

Siva Krishna Gontla
Siva Krishna Gontla

Reputation: 58

it is very straight forward. You are checking the username and password given by user with the usernames and passwords stored in the database right. The moment you notice that he is a valid user you can do the following: Create a simple POJO (Plain Old Java Object) class with id,username,password,email,address,gender as object variables, generate getter methods and setter methods with the help of IDE (or) you can write yourself. Once you feel he is a valid user retrieve all these details from the database with a simple "select *" query, create an object of POJO class, set the object variables with values you receive from database query and then pass this POJO object to the view where you will display the username. Please do check how to display information from database in a webpage using struts2. I hope this helps you.

Upvotes: 0

Related Questions