aspose file tools*
The moose likes Portals and Portlets and the fly likes Validate content from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Validate content from JSP" Watch "Validate content from JSP" New topic
Author

Validate content from JSP

thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
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

Joined: Mar 23, 2007
Posts: 60
Are they really no suggestion to this
Raphael Okochu
Greenhorn

Joined: Jul 17, 2009
Posts: 22
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.


SCJP 5
thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
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.

 
Consider Paul's rocket mass heater.
 
subject: Validate content from JSP