Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getResourceAsStream(path) Path issue during validation

 
Ayyappan Selvaraj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to validate the fields in my action class. I use the following code snippet.

But I find that the input streams 'rules' and 'is' are null. I guess that the path of the xml file is not being recongnized by the jar.

Please help...


String path =(String)req.getRealPath("/WEB-INF/").replace('\\','/');
String outPath=path.concat("/validator-rules.xml");
InputStream rules = Thread.currentThread().getContextClassLoader().getResourceAsStream(outPath);
final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/WEB-INF/validation.xml");

ValidatorResources resources = new ValidatorResources(new InputStream[] {rules, is});
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a reason why you're not validating in the recommended way... by using an ActionForm that extends ValidatorForm?
 
Ayyappan Selvaraj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes... Im using Ajax in my JSPs. So I require to validate every field on the screen using on blur...
 
Ayyappan Selvaraj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks its working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic