Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
    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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

why do i get few junk characters in the XML response

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
response.setContentType("application/x-java-serialized-object");

OutputStream outputStream = response.getOutputStream();
System.out.println(outputStream);
ObjectOutputStream output = new ObjectOutputStream(outputStream);

output.writeObject("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<text timestamp=\"08:45:00.000\">"+
"The deadline of <name>homework 1</name> is"+
"<emph>March 9th 2001</emph>."+
"</text>");
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
"indianguy guy,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names.

You can edit your display name here. Thank you for your prompt attention!

-Marc
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Report post to moderator
Don't use an ObjectOutputStream - it's meant to be used for serializing objects, not for writing plain text (or XML) files.
 
venkat
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
I need to capture the xml output in another page and unmarshall the xml
code.how can i capture the xml code if i dont use object output stream
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question in more than one forum. As you have corss-posted this issue in the Servlets forum (which is a more appropriate place than here), I've closed this topic.

Also, see that other post for a message regarding your still invalid display name.
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic