This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes unbale to view xml file in browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "unbale to view xml file in browser" Watch "unbale to view xml file in browser" New topic
Author

unbale to view xml file in browser

madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi,
i developed xml file..i want to view that xml file in browser...but im unable to do..it is showing in console..but i need is in browser..can any one help me out..here is my code..its urgent.



thanks,
madhu.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

try changing the content-type to text/xml or application/xml...
Also, pass the PrintWriter object, i.e pw to readdata function and in readData function, use PrintWriter object to output xml data instead of System.out.println();


Regards, Prasad
SCJP 5 (93%)
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi prasad,
i tried..but im unable to view..im getting output as..




but i need is my full xml file..
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

Hi madhu,

now, see my edited post,above.. Hope that solves your problem..
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi,
i tried eventhough im not getting...here the code what i changed..




and im getting output as

madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi prasad,
have you checked my code...
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

madhuri kunchala wrote:hi,
i tried eventhough im not getting...here the code what i changed..




and im getting output as



Hi Madhu, I have changed your code, please use above code...
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi prasad,
i tried what you had given..im not getting the xml file..im getting the output as

Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

I tried in my PC, its working.. By, the By, You are viewing the XML file, or creating a new file.. i.e MyXml.xml, is alredy existing or not..
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

Anyway, Here is the code, copied form my system, which is working.. please let me know, if you still have any problems...
In the below code, just change the part to refer to your XML file..

madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
hi prasad,
thanks for your support..i got it..i came to know where i went wrong..thanks a lot...
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
prasad,
i had another doubt in the previous question..im using the following code...it is not providing me the answer..here is my changed code..im not giving directly the file path..im using config properties..can you once check it..

Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

madhuri kunchala wrote:hi prasad,
thanks for your support..i got it..i came to know where i went wrong..thanks a lot...


You are welcome...
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

Why exactly are you using config.properties, because, here i see, you are giving login.xml file name, directly..
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i had sended you to your inbox message
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

I would recommend, you to use getResourceAsStream for loading .properties file.. Anyway, are you sure, your properties file is loaded, try printing gprsLoginPath, bfore appending Login.xml and see, what it is printing..
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i tried ..it is taking and printing the value what i had given
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

Then, what it is showing in the browser, any exception, or blank page..
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
i changed the code like this



and the output is

'E:/proj/gprs
hello'

Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

That is fine.. What is the error you are getting, not able to view the XML file, means, are you getting any exception? or blank page?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
im getting error as

XML Parsing Error: junk after document element
Location: http://localhost:8080/proj/viewXml
Line Number 254, Column 1:<b>Xml File Viewed Successfully</b>
^
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

comment out this line, and tell, what you are getting...
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
great i got it..thanks a lot very much......another doubt..dont feel ..
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

Its ok.. no problem.. tell, whats the doubt?
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
in my project i had done validations for the textfield..my problem is if i enter 'NULL123' it is taking..but i need it should not take...i tried separately..it is working..when i code that in my jsp page..it is not validating...can you help me out..shall i send the code
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

Ya.. sure..you can send me that one, Also, create a new topic for that one.. This topic, is growing lengthy..
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
can i send it in your private message
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

ya.. send it.. no problem..
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

:shock:

Please see UseTheForumNotEmail.

Although in this case, considering the amount of code and back-and-forth, and topic-switching, it's just as well.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

David Newton wrote: :shock:

Please see UseTheForumNotEmail.

Although in this case, considering the amount of code and back-and-forth, and topic-switching, it's just as well.


Sorry David, from now on, I would not encourage questions to be sent to my private messages or mail..
madhuri kunchala
Ranch Hand

Joined: Mar 30, 2010
Posts: 350
sorry by using the mails...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unbale to view xml file in browser