wood burning stoves 2.0*
The moose likes JSP and the fly likes How to return an object instance by JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to return an object instance by JSP" Watch "How to return an object instance by JSP" New topic
Author

How to return an object instance by JSP

chen Jyun
Greenhorn

Joined: Nov 13, 2011
Posts: 2
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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

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.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
chen Jyun
Greenhorn

Joined: Nov 13, 2011
Posts: 2
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!
Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
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.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to return an object instance by JSP
 
Similar Threads
Can I pick your brains on globally accessing XML resources?
XML DOC toString.
session variable
Not able to get default value of XSD element in Java object
Change Encoding of XML document.