| Author |
reading XML in JSP
|
Nikki Agr
Greenhorn
Joined: Nov 09, 2008
Posts: 13
|
|
Hi there, I am trying to read an XML file using the DOM Parser in JSP. The only way it is working for me is when I refer to products.xml by its absolute path. How do I make it work using its relative path? Please advise, thanks!
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
you can get the context path , by (Please check out API, I'm not remembering them now) and append it the path relative path of .xml file (relative to web app) Try this,,
|
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
|
You really should not be doing this type of processing in a JSP. In any case, it's independent of JSP so I've moved this to a more appropriate forum.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Relative path? Well, that isn't anything to do with XML. That's a question about what the current working directory is in your application server, which appears to be Tomcat. But as I understand it, that's not defined by the servlet specification, so you shouldn't be relying on knowing what it is. Something like what Sagar suggested should work, though.
|
 |
Yves Zoundi
Ranch Hand
Joined: Aug 31, 2008
Posts: 47
|
|
|
If you already use JSTL in your JSP pages, there are also tags libraries which could leverage your code.
|
Author of VFSJFileChooser and XPontus XML Editor
|
 |
 |
|
|
subject: reading XML in JSP
|
|
|