How to handle data validation in a JSP page.

R

Rich Hajinlian

I'm wondering how folks handle field validation on jsp pages? I have a jsp
page and the
form variables need to be checked for proper values (numbers only, Date
format's and users not entering required info).

I have a bean managed entity bean and I was wondering how people
implement this type of validation logic. I'm sure it's not to be
implemented in the
..jsp page and should be checked in a session/entity bean? Another
question.......Is a session bean even necessary or should my entity bean
handle communications with the jsp pages?

Thanks for any help in advance.

J2EE newbie :)
 
S

Sudsy

Rich said:
I'm wondering how folks handle field validation on jsp pages? I have a jsp
page and the
form variables need to be checked for proper values (numbers only, Date
format's and users not entering required info).

Struts anyone? Seriously, if you're talking about anything more
sophisticated than just a few pages then you might want to migrate
to a MVC framework. The learning curve is steep but it will handle
tasks like validation very nicely.
 
C

Chiron Paixos

I'm wondering how folks handle field validation on jsp pages? I have a jsp
page and the
form variables need to be checked for proper values (numbers only, Date
format's and users not entering required info).

I have a bean managed entity bean and I was wondering how people
implement this type of validation logic. I'm sure it's not to be
implemented in the .jsp page and should be checked in a session/entity bean?

Well it depends on the kind of check you want to do. In case of simple
checks like numeric value, ranges, dates etc. they can be done in the
..jsp already. Why do you want to send the data to the server for
simple validation tasks?
For data validition tasks is the customer registred you'll need to
check against your database and can't do it in the jsp.

Maybe you should read a book about EJBs before you continue your
project. As a rule of thumb: entity beans take care of data
persistence, session beans take care of the business logic.

Another question.......Is a session bean even necessary or should my entity bean
handle communications with the jsp pages?
The communication between the client (using a browser to display the
jsp and entering the data) and the server is called a session - this
should answer your question.
 
R

Rich Hajinlian

Chiron Paixos said:
bean?

Well it depends on the kind of check you want to do. In case of simple
checks like numeric value, ranges, dates etc. they can be done in the
.jsp already. Why do you want to send the data to the server for
simple validation tasks?

Thank you for your suggestion. These checks are simple but as you can
imagine they can get rather involved. And since many pages of .jsp may have
the same checks I envision having a bean that can do all/most of the
checking. But,,,,,,,,,correct me if I'm wrong here but even if you do the
check in the jsp "page" it is handled in the server via the scriptlet engine
anyhow.
For data validition tasks is the customer registred you'll need to
check against your database and can't do it in the jsp.

Maybe you should read a book about EJBs before you continue your
project. As a rule of thumb: entity beans take care of data
persistence, session beans take care of the business logic.

Yup, know bout that rule - thank you. But to be more specific, if you do
all the data validation checks in your .jsp page why would you need a
session bean if your just storing the data to the DB? I can envision a
session bean for the (as previously discussed) data validation but
..............would I need a session if I just check in the page and then
simply use an entity bean to store the data?
The communication between the client (using a browser to display the
jsp and entering the data) and the server is called a session - this
should answer your question.





----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---

Again, thanks for your tips and suggestions.

Rich
 
T

Tim

Rich said:
Thank you for your suggestion. These checks are simple but as you can
imagine they can get rather involved. And since many pages of .jsp may have
the same checks I envision having a bean that can do all/most of the
checking. But,,,,,,,,,correct me if I'm wrong here but even if you do the
check in the jsp "page" it is handled in the server via the scriptlet engine
anyhow.

Not if you use javascript, which is client side.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top