Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validate content from JSP

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I would like to have a suggestion how to validate the JSP Input that the user have Done.


Is it correct to do it in the 'Processaction' when the form is submitted.




 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are they really no suggestion to this
 
Raphael Okochu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas, you can validate user input using either JSTL or a Bean..
You will have to call "<portlet:renderURL/>" when the form is submitted in either case, hence validation is done outside the portlet class.
Using JSTL:



But with more complex validation, such as verifying that a parameter holds an email address or a credit-card number,
or that a value matches a list of valid values held in a database, we can do a lot better with a
bean. Using a Bean:

Here is your jsp code:


Here is your bean class:


It would be preferable to use a bean because its cleaner, it encapsulates and separates validation code from the JSP.
I hope this helps.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input.

I can see that it is the Approach to use when validating a Form.


As a Newbie it can be quite confusing when things are Done in many ways, Scriptlets, javascripts, JSTL and Beans.

Thanks again for the Guidence.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic