This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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?
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.
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.