Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Entry Flow Servlet

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65116
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic