wood burning stoves 2.0*
The moose likes JSP and the fly likes please help with jsp design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "please help with jsp design" Watch "please help with jsp design" New topic
Author

please help with jsp design

Ryan G Johnson
Ranch Hand

Joined: Nov 11, 2004
Posts: 33
I did this with a servlet and now I'm trying to figure out how to do this with a jsp.

I have a screen that displays data
If there is no data you get a message saying no data

So I think that would be 2 jsps.

If you hit the edit or save button you get a new screen that allows you to input data. If you hit save or cancel you go back to the 'display data' screen. I also need the ability to do next and previous on the display data screen.

I have this done in servlets, I am having trouble figuring out how to design this for servlets. I am figure the following.

1. jsp for display data screen
2. jsp for the display data screen with no data
3. jsp for the add/cancel screen

Ok that is the html part. How do I manage the logic? can I do an 'action=''> and pass this to a javabean? then have the java bean act as a dispatcher with all my logic in it? I can't figure out how I write a class to manage all my logic for the jsps. How do I call the dispatcher class? how do i have the dispatcher class then call a jsp page?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30299
    
150

Bobbie,
You are on the right track with trying to keep the logic out of the JSP. It is standard to call a servlet which does the logic part (or delegates that responsibility to beans) and stores the result in the HttpRequest. The JSP gets the data from the request and displays it with the HTML.


[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
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Hi Bobbie,
I think JSP should not contain the business logic.
It is pure for presentation.

My understanding to solve your case like this:
* We will have 2 screen to handle that. There are 'Search' screen and 'Add' screen. The landing page for this application is 'Search' screen, so when user clicks the link either from menu or from another screen, the 'Search' screen will be showed.
* 'Search' screen has two parts. First is Search criteria where user can input the constraint when system do searching process. Second is list of result from searching. If there is no result, this part will show no data.
* 'Search' screen has a link to 'Add' screen so that user can add new data.
* 'Add' screen has 'Save' button to save that new data. In this screen has 'Back' link so that user can back to 'Search' screen.
* We have a servlet to handle all requests from those screen and dispatch to a proper screen.
* Every request will be forwarded to a class which contains bussiness logic. In this class, those requests will be processed whether saving process or searching process.

Correct me if I am wrong
Hope this helps

daniel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help with jsp design