I'm building a website, there is a JSP that collects user information which when submitted, takes you too another JSP, which puts this information into a bean. The problem is, I want to be able to use the properties of a bean.
Firstly, I cannot seem to use left(less than) and right(more than) arrows in this thread, so I'm letting L and R be the left and right arrows respectively.
For example, if I wanted to initialize the String NAME with "QWERTY", I just type into the JSP L%! String NAME="QWERTY"; %R So how could I store Ljsp:getProperty name="details" property="first" /R into NAME instead of "QWERTY"??? ANY IDEAS [ August 04, 2005: Message edited by: Bear Bibeault ]
Hi, the reasons are fairly straightforward, I need to collect some user information in a JSP, then in another JSP(or servlet) check that all the fields are non-empty and of the correct form, if they're not, I need to go back to original JSP to re-enter information.
If all the information is correct, then I can use a bean to put this info into an excel spreadsheet (in a servlet)
For example, if I wanted to initialize the String NAME with "QWERTY", I just type into the JSP L%! String NAME="QWERTY"; %R So how could I store Ljsp:getProperty name="details" property="first" /R into NAME instead of "QWERTY"??? ANY IDEAS
Wait, are you trying to retrieve the the value from the bean, or set the value in the bean to what was submitted? Or both?
then in another JSP(or servlet) check that all the fields are non-empty and of the correct form, if they're not, I need to go back to original JSP to re-enter information.
So why aren't you using a servlet? Using a JSP to do anything other than render a view is like using a wrench to drive a nail.
Joined: Apr 11, 2005
Hi, I need to check the information that was previously submitted is in the correct form, I can do this ok, by using request.getParameter(...), but not sure if I need to use a bean, so that when the user has missed some information, he goes back to the jsp and the partially entered fields are still there.
Assuming, all the information has been sumbitted correct, I know how to put this into a bean, but not sure how to get the information into a seperate servlet(excel file) to be looked at later.
While there are many ways to do what (I think) you are trying to do, the high-level mechanisms could be something along the line of:
1) The form is submitted to a servlet whose purpose is to process the form data.
2) The servlet validates the data. Whether it does this directly, or whether it delegates the validation to an abastraction of the submitted data (a bean, if you will) is up to you. I tend to favor the abstraction approach.
3) If validation succeeds, the servlet goes about its merry way processing the data. If you've gathered the data into a bean, that's the way the data can be carried along through its subsequent processing.
4) If validation fails, the servlet forwards back to the submitting JSP. Since the request is forwarded, the request parameters are still available on the request and can be used to initialize the form fields using the value attribute of the form elements.
Joined: Apr 11, 2005
OK, I've managed to get all the information from the submission form, and enter it into a bean. I need this bean information stored in a servlet(as an excel file). Basically, for each user, a bean collects their information, and this needs to be stored in the servlet. Not sure exactly the best way to do this, will do some reading now. Any help is appreciated