wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes reading XML in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "reading XML in JSP" Watch "reading XML in JSP" New topic
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: 2902
    
    1

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: 60822
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reading XML in JSP
 
Similar Threads
Unknown problem with Tomcat and Axis2
Using a parsed XML document
Documet object is returned null
Open word doc in folder which is not in weblogic server 10.3 context path and IE 7.0 Browser
New to Java. Can you help with whit this (XML) ?