This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Data Entry Flow Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Data Entry Flow Servlet" Watch "Data Entry Flow Servlet" New topic
Author

Data Entry Flow Servlet

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ok, I don't think my Subject makes much sense. Currenty, for some specific data, we use a Form with every field, drop down, checkbox, list, etc available. It's functional, but very ugly and not very practical.
What I want to do is create a flowing data entry form. You've all used them. You start out entering one things and you click next to go to the next entry screen. Sometimes you are directed differenty based on your choses options, etc.
So I have an idea in my head of how this should work, and thought I would run it by everyone to see if I am on track or way off or sort of right.
Basically I will have a single Servlet controlling this flow. No, this is not a Front Controller. I am using a multi servlet environment but I want to use a single Servlet for this task.
I think how it should work is as each bit of data is entered into the form, and I click a Continue or a Next button, I will forward to the same Servlet and in that Servlet I will check some request params for values that will help me determine the VIEW I need next. I will put all my data into the request as I go along the different views, but since I am forwarding the entire way, I should be able to keep a single request active through the entire session of events.
So in my Servlet I will have some IF statements checking request params for specific values and then forwarding on to the appropriate actions. Basically, the servlet will be doing what a Front Controller does, but not for the entire app.
Is this the correct approach for something like this or do I need to be looking at going about this a different way.
Thanks.


GenRocket - Experts at Building Test Data
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I will forward to the same Servlet and in that Servlet I will check some request params for values that will help me determine the VIEW I need next. I will put all my data into the request as I go along the different views, but since I am forwarding the entire way, I should be able to keep a single request active through the entire session of events.
This worries me. Every multi-page web form I have ever seen has needed a trip back to the server each time one of the pages is completed and the next page of the form generated and returned. This is not a single request, this is a session!
Are you sure you can manage this in a single request (ie, one URL from the browser, returning a single page of HTML) ?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Unless I misunderstand what you are asking, you are talking about a multi-page form.
As Frank pointed out, you really can't do this under the control of a single request. Think about it this way: you only get one response per request, and you need one response per page.
I've seen this handled in one of two ways:
1) As Frank pointed out, you can store the aggregate of the form data in a seesion where your pages and servlet(s) can retrieve them.
2) For environments where the session cannot be used for whatever reason, you can store the aggregate of the form data on each and every page, making the data for "other pages" hidden inputs on each page of the form. That way you can shuttle back and forth across pages and keep track of the info from the others. (Assuming that you set the values of the inputs from the submitted params on each page).
The first approach is obviously the most straight-forward.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Yeah, ok, I'm a dumbass. I need to use the session to store my page to page information. Makes more sense anyway.
So with that being said, I am off to the races so to speak.
Thanks Frank.
Thanks Bear.
 
 
subject: Data Entry Flow Servlet
 
Similar Threads
Making a Post request using Ajax
Form Beans necessary?
Use of DAO as a Command?
about struts
Using servlets