Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web Application

 
vasuma patel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vasuma patel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A similar pattern, must read
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic