• Post Reply Bookmark Topic Watch Topic
  • New Topic

parsing XML  RSS feed

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
document = builder.parse("/jsp/mail.xml");

My mail.xml is in /jsp but i m getting 404 error

is it the right way to locate the file or there is other way...

i have also checked with my war file there is mail.xml in jsp folder.

ERROR IN BROWSER WINDOW :
======================================
HTTP Status 404 - \jsp\mail.xml

--------------------------------------------------------------------------------

type Status report

message \jsp\mail.xml

description The requested resource (\jsp\mail.xml) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.17

[ December 25, 2006: Message edited by: Jigar Naik ]
[ December 25, 2006: Message edited by: Bear Bibeault ]
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this problem a while back, but with a swing application. Have a look at this...

http://www.coderanch.com/t/380705/java/java/Playing-sound-jar-file
 
Kamesh Rao
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your .xml file is not in the classpath. Please check whether this .xml file is in WEB-INF/classes folder or not. Your program should work if it is present there.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Classpath? If that code is getting an HTTP 404 response then it looks to me as if it's Javascript code. In which case Jigar would be asking why '/jsp/mail.xml' doesn't return it when the browser treats it as a URL.
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My dir structure of sendMail.war file

jsp>>mail.xml
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this line works...

//document = builder.parse("C:/Documents and Settings/.../Desktop/mail.xml");

but when i give the path to .war file its giving 404

document = builder.parse("/jsp/mail.xml");
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jigar Naik:

document = builder.parse("/jsp/mail.xml");


That's because you are giving it a file-system-relative path. Do you really have a folder named /jsp at your file system root? Of course not, it's relative to the web application root.

So you need to find the actual path to the file programatically. Have you checked the servlet APIs for appropriate methods?
 
Kamesh Rao
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use class Class method below
yourclassname.getResourceAsStream("/jsp/xx.xml");
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thamks guys..
well i did it using the folloing function

String s1 = application.getRealPath(".");
document = builder.parse(s1 + "/jsp/mail.xml");
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!