Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

JSP Form validation

Thread view: 
teser3@hotmail.com - 03 Aug 2007 02:13 GMT
I want to create a JSP Form page (first.jsp) on Tomcat 4.1.27 with a
form that has about 20 input entries where the form will validate all
20 fields and show validation errors on the same page as the original
form page (first.jsp). For example, if someone has a blank entry on
the Firstname field then it will show this message in red next to the
field: First Name is required.

If the data passes the validations it will populate an Oracle
database.

Please advise any suggestions on how I should do this.

I was thinking of submitting the fields to a Controller servlet then
use the Enumeration class to get all field values where I would check
for blanks and valid email address. I assume I would not use a bean
and have a getter and setter method for all 20 fields?

//  Servlet controller part:
// Get the values of all request parameters
       Enumeration enum = req.getParameterNames();
       for (int i; enum.hasMoreElements();i++ )
       {
           /*
           put in ArrayList and
           validate and if not passing validation then pass it down
to next part
           */
       }
....
//next part - take value/s that dont pass and put in session variable
and redirect back to JSP

I dont have Struts and need to know the best way to do this.
Can anyone give me more example or ideas on this?
mich - 03 Aug 2007 02:23 GMT
>I want to create a JSP Form page (first.jsp) on Tomcat 4.1.27 with a
> form that has about 20 input entries where the form will validate all
> 20 fields and show validation errors on the same page as the original
> form page (first.jsp). For example, if someone has a blank entry on
> the Firstname field then it will show this message in red next to the
> field: First Name is required.

what I did is when the send button is pressed it goes to a JPS/URL that
captures each field by it's HTML name and checks them. If there is an error
then it's

     <jsp:forward page="UserError.jsp">
        <jsp:param name="text" value="<%=message%>" />
     </jsp:forward>

otherwise

<jsp:forward page="Confirm.jsp"/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.