• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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:


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 ]
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.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!