Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to return an object instance by JSP  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently I am writing a JSP for create the program of XML Document,

create the program is successful, but how to return this object instance?

ex: Document doc = docBuilder.newDocument();

how to return this doc by jsp??

Thanks
chen
 
author & internet detective
Sheriff
Posts: 38564
654
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Document is a Java object. It doesn't make sense to return a Java object in a browser. Instead you would return the XML character data to the user for display. (Also, this is better done in a servlet than a JSP. JSP is about presentation.)
 
chen Jyun
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you answer,

Oh sorry ,I am not return a Java object in a browser.

I want to return this object "Document" for client to prase,

and that result displayed on the eclipse console,

so how should I do ?(return document object for client)

Thanks!
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have not done for xml
But if you want a json object you can use json tag library in jsp to create a json object.
Which will get by the request from the browser.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To return this document in a servlet:



Thats the basic pattern to write the document out.
In this case is uses the servlet output stream to provide the xml response to the client.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!