aspose file tools*
The moose likes JSP and the fly likes Web Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Web Application" Watch "Web Application" New topic
Author

Web Application

vasuma patel
Greenhorn

Joined: Mar 07, 2006
Posts: 15
This is a general application question, not necessarily JSP sepcific. I thought this belongs here but feel free to move.


I need to create a web app which has three pages.User is already known by the time he comes to my application. Home page displays a list of available materials ( A check box, an image and a descritpion in each row, several rows in the page). There are submit and clear in the end. User selects as many of the materials he likes and clicks submit. I need to store the sellections in the database which has the details of the quantities of the materials in tables.

Next page is a confirm order page where I display all his selections( check box, image and description again) and his shipping details in a table at the end. I get his personal details from another table. He is asked to make any corrections if needed. Once he makes any changes the confirm order page is redisplayed with changes. Next page is the thank you page where he is thanked and details of when he can expect the materials to arrive.

Now I am thinkng of using JSPs for the three pages. I am thinking about having two java beans one for the selctions and one for his personal details.

My questions are

Should I display home page by getting data directly from database? Should I populate beans and then get data from them?

I thought each row in database corresonds to a row. So should I have multiple beans populated for his selctions and put them in a map and send it in request? Or should I create a list of his selections and put it in the bean? In whcih case bean should have a collection?

I know jsps and servlets individually but never usded java beans. This is a small application in which I need to connect to DB, use beans and pass them back and forth.

Request experienced people to suggest a general flow to follow.

Thanks very much in advance.

vasuma
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

Vasuma,
Should I display home page by getting data directly from database? Should I populate beans and then get data from them?

It is good to avoid accessing the database directly from your JSP. That way you get a cleaner design.

I thought each row in database corresonds to a row. So should I have multiple beans populated for his selctions and put them in a map and send it in request? Or should I create a list of his selections and put it in the bean? In whcih case bean should have a collection?

Personally, I would favor putting a collection of beans/objects in the request from within a servlet. Then you can forward to the JSP and display the page. Any of the options you listed are valid though. You could put objects directly in the request. Or you could put the objects in a bean (that has a collection of other beans) and put that bean in the request.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
vasuma patel
Greenhorn

Joined: Mar 07, 2006
Posts: 15
Thanks very much.

So I need to have a bean which has the individual properties and getters and setters. In the servlet I need to access the database and populate the beans and send them to the JSP in a collection where jsp reads iterates through them and displays. User selections are a bunch of these beans as well which are put in the request and sent to the servlet where it is forwarded to the second page. The user data bean is populated by accessing the database and the populated bean is passed to the jsp.


Can I do anything different / better?

Thanks in advance.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
A similar pattern, must read
 
Consider Paul's rocket mass heater.
 
subject: Web Application