Punit Jain wrote:
after inserting, it redirecting to success.jsp, and from success.jsp i am redirecting to ViewData.jsp and there i am print the values from getters.
do i need to also bring those values in success.jsp??
or what i am doing wrong??
i have two more class, one is simple html form and second is bean class, which has setters and getters.
You created Item Bean object. i mean a new Item bean object which does have all default values.
You did not set any property of the Item bean object. so when retrieving you will get null values. as you did not set item bean object..
check in while loop. You are getting the property without being set..so first set the propety in the while loop.then call the getters..
e.g. String query = "SELECT name,quantity,brand,price FROM items";
out.println(rs.getInt(2)); //print quantity
Set the properties of an Item javabean.
Add the individual Item javabeans to a collection (e.g. list of Items).
Set the collection (e.g. list) of Items as an attribute to a request (or a session if you need access to this data when the request is over).
Pass on the request from the servlet to the relevant jsp page.
In your jsp get the request (or session) attribute and loop through the collection (e.g. using the JSTL forEach tag) and use EL to access the Item's getter methods.
I think you are saying that you only want to display the values of a single Item (the Item that has just been inserted into your database and not all the items in your Item table). Is that correct?
Set this Item object as an attribute to the request (or a session) (e.g. request.setAttribute("item",ii);)
Punit Jain wrote:
The function getItemName must be used with a prefix when a default namespace is not specified
Quick! Before anybody notices! Cover it up with this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earthhttps://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter