File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Repeated code in Servlet and Bean

 
Dan Parsons
Ranch Hand
Posts: 70
  • 0
  • 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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic