| Author |
Inpust stream path issue
|
Ayyappan Selvaraj
Ranch Hand
Joined: Sep 20, 2004
Posts: 63
|
|
I try to get the contnets of a file in my 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. 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");
|
 |
ramprasad madathil
Ranch Hand
Joined: Jan 24, 2005
Posts: 489
|
|
That's servlet code. In web applications, an easier and fool proof way to get handles to an input stream is to use the ServletContext's getResourceAsStream("path") method where path should begin with "/". The "/" represents the servlet's context. Thus ram.
|
 |
Ayyappan Selvaraj
Ranch Hand
Joined: Sep 20, 2004
Posts: 63
|
|
Ram, its working now. Thanks you very much. and you know Struts?
|
 |
 |
|
|
subject: Inpust stream path issue
|
|
|