aspose file tools*
The moose likes Struts and the fly likes getResourceAsStream(path) Path issue during validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "getResourceAsStream(path) Path issue during validation" Watch "getResourceAsStream(path) Path issue during validation" New topic
Author

getResourceAsStream(path) Path issue during validation

Ayyappan Selvaraj
Ranch Hand

Joined: Sep 20, 2004
Posts: 63
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

Joined: Feb 15, 2005
Posts: 4864
Is there a reason why you're not validating in the recommended way... by using an ActionForm that extends ValidatorForm?


Merrill
Consultant, Sima Solutions
Ayyappan Selvaraj
Ranch Hand

Joined: Sep 20, 2004
Posts: 63
yes... Im using Ajax in my JSPs. So I require to validate every field on the screen using on blur...
Ayyappan Selvaraj
Ranch Hand

Joined: Sep 20, 2004
Posts: 63
Thanks its working now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getResourceAsStream(path) Path issue during validation