All I am saying is I am not able to get the validated correct output immeadiately after submitted the form. What I am getting is a false output for the null parameters automaticlaly supplied and then when I supply my input, I am getting the appropriate output. How do I make sure that I do not get the invalid output at first.
Any example would be appreaciated. Is that got to do with the usebean tag parameters or exactly what do I need to change so that I get the appropriate response. Please note, there is only one form here and I am doing the validation using a bean class.
That's not an appropriate or best practice way to structure a web app. Your form should be submitting to a servlet, not a JSP, for validation.
Perhaps this article could help bring you up-to-speed on modern web app structure.
(a) form.jsp page...
In the above form, I have two parameters which are input1 and input2 and onsubmitting, I am posting that to the same page....I donot know how far that is correct...
myBean.java class has a verify method which takes the input parameters by saying getInput1() and getInput2() respectively and validate by manipulating those parameters and return true / false based on the business logic.
In the scriptlet of the JSP, I am printing out the output based on the boolean obtained as a result of verify funtion obtained.
I am sorry, I am not authorzed to put up the snippet, but I guess this should be good enough to have a glimpse of my template.
and this result is fetched in my jsp(which has the form..) and I have set of println statements based on those results of the function...
It will be great if you could let me know how to proceed smoothly in this issue...
The general procedure is: Servlet -> Validation & Business Methods -> JSP's for display
You always strive for a separation of concerns. That means, separating business logic from the presentation. And that means, a form gets submitted to a servlet, the servlet does it's validation and business logic, and then forwards to the JSP (which could be the same JSP you used for the form, but it doesn't make much sense to me, depends on the case) which displays the results generated by the servlet.
sidharth johar wrote:and the action is done on the same page
Which is the problem.
I suppose that is a mistake
Yes. It is.
I want somebody to correct me
Did you read the article I linked to? It will correct you.
Do I need to post that to some other page and call the function that I want to
You should never post to pages. Post to servlets.
Cant I just have a single jsp that does all of this for me? I am neophyte in this. So please bear with me.
Then it's important to learn proper habits at the outset. If you are a novice to JSP, I'd recommend this article as well.