• Post Reply Bookmark Topic Watch Topic
  • New Topic

Repeated code in Servlet and Bean  RSS feed

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Servlet and JavaBean working with my formPage.jsp where the jsp has input values and they are validated using JavaBean and Servlet. It works where it also gives a message of how many validations are needed and gives field validation message next to each field that has a validation issue.

Now I want to make it more efficient because I seem to be double coding where I am doing validation in both my Servlet and Bean. For example this condition is repeated in both Bean and Servlet:


Here is my Bean condense to show just one out of my 10 fields:


Servlet Controller condense to show 1 out of the 10 fields:

JSP:


I am using Scriptlet because my environment will not allow EL or JSTL or Struts. We are using Tomcat 4.1.27.
[ August 07, 2007: Message edited by: Dan Parsons ]
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thought..

Remove the validation from your servlet and have the bean return a list of errors after all the fields have been populated.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!