• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to parse an XML Document residing in the remote Windows NTserver.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have tomcat installed on an NT server in the 'D' drive. I have a jsp file which uploads an XML file for operation from the server. The sample code is as follows:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("d:/tomcat/webapps/examples/jsp/Test/Test.xml");
But this gives the following exception:
java.net.MalformedURLException: unknown protocol: d
The same code works fine on Windows98. Can anyone tell me the reason for the exception and how to overcome it.
Thanks in advance.
-Jayarani
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jayarani,
If u r working under a server then u should specify the correct url path to access the file.for eg. http://localhost:8080/jsp/Test/test.xml
For parsing a remote xml file many methods are there.One of the flexible methods is using <xtags> provided by apache.
It is easiest one to implement all your applications.The concept of xtags is same like xsl,but the difference is in xtags you can embed your xpath and xslt transformations in jsp as well as u can parse an XML,which resides in any server.To my knowledge Parsing is not possible in xsl.
To know more about this just visit jakarta.apache.org/taglibs/doc/xtags-doc/intro.html.
From there download xtags library..In that zip file u could find
xtags-examples.war file.Again if u extract this war file then u will find all necessary examples for your application.
In your case the code would be.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test application</title>
</head>
<body>
<xtags arse url="http://localhost:8080/jsp/Test/test.xml"/>
your further implementaions here
.......
.......
if u have any doubt or difficulty then feel free to ask me again..
all the best,
kind regards,
paramaguru
 
reply
    Bookmark Topic Watch Topic
  • New Topic