1

I have read this interesting question how to pass bean validation error in JSF and I understood how to pass bean validation error into a JSF page. What I ask you is it possible to pass bean validation error using JSP. I'm not using JSF. How can I get bean validation error into a JSP Page in particularly into a form page?

@Entity
@Table
public class User implements Serializeable 
{
   @Email(message = "Please insert a valid e-mail")
   private String email;
}

Let's suppose to have this entity where I have added a constraint to validate e-mail. I would like to show the error message in a jsp page.

Community
  • 1
  • 1
Mazzy
  • 13,354
  • 43
  • 126
  • 207
  • you might want to check out these links http://www.coderanch.com/t/286390/JSP/java/jsp-form-validation-bean-int and http://exampledepot.8waytrips.com/egs/javax.servlet.jsp/myform.jsp.html – Rachel Gallen Jun 12 '14 at 13:45
  • Unfortunately that is not bean validation. I mean for bean validation putting annotations on the fields and associate to them messages errors to show to the user – Mazzy Jun 12 '14 at 13:50
  • Some Validations can contains keys and scripts that are not available in JSP. You may need to write your own Framework. – Grim Jun 12 '14 at 13:55
  • Plain JSP? You are not using a framework? Many frameworks offer integration with BV. If you are not using a framework, how do you call the validation. If you do it manually, you can process the constraint violations yourself and add the appropriate messages into the servlet context. – Hardy Jun 13 '14 at 08:15
  • @Hardy.I'm using Java EE. 7 with GlassFish it has been validation but I don't know how to get error message in jsp page. – Mazzy Jun 13 '14 at 08:25

1 Answers1

0

Many frameworks do this (i.e. Spring MVC and Struts 2).

Here's an example of how to do it on Spring:

http://www.mkyong.com/spring-mvc/spring-3-mvc-and-jsr303-valid-example/

Andres
  • 10,561
  • 4
  • 45
  • 63