Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing a org.w3c.Document from a Servlet to a JSP  RSS feed

 
Markus Neumaier
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm trying to pass a org.w3c.Document, using the session object, to a JSP.

Servlet:


nextJSP.jsp:


I'm getting this exception:

I tried removing the <x:out ... which results in no error, but also no output ;)
I also tried to print the whole xml in the Servlet, that worked fine too.

I'm kind of lost, how to debug this any further.

Thank you in advance

Markus
(I apologize in advance for my English, it's not my first language)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Markus,
Welcome to CodeRanch! Don't worry, your English is perfect.

I think the problem is that x:out isn't designed to print out Document objects. What are you trying to do in the JSP? If just print out the XML, why not convert it to a String object in the servlet and set that as a session attribute? (or request attribute since it seems likely you don't need it on future pages.)
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need an <x:parse> statement in there, at least that's how I read http://www.ibm.com/developerworks/java/library/j-jstl0520/
 
Markus Neumaier
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the Answers.

The thing is, I'm already printing a XML (or rather a org.w3c.Document) by using the <x:out...



The Getter-Method "requestDoc" returns a Document and from there i can access is by using the var "doc".
Only difference to my approach this time is, that i try to store it in the session-object (also tried the request object).
I'll try to create a test scenario in which I get the Result just the same way, as above. But this won't be suitable for my Application.

Edit: my search results said that you don't need, or can't, parse a Document. You only parse "raw" XML-Files.
Edit2: the XML File is generated after my request. And i only want to print certain parts of it. So i don't think converting to a String would be the right approach.
 
Markus Neumaier
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem Solved :)

you can access the objects only with .
I also tried to create 2 Objects with the same name, in this case he uses the one attached to the request object and not the session object.
I think he works up the scopes from Page to Application (But didn't test all cases).

Thank you for your help :)

Best Regards
Markus
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my search results said that you don't need, or can't, parse a Document. You only parse "raw" XML-Files.

That's possible, I only saw that document and may have misinterpreted it. I would generally handle XML in the servlet, and then pass the extracted data to the JSP, instead of using the XML JSTL tags.

Instead of "${session.resultDocument}" also try "${sessionScope.resultDocument}" and "${resultDocument}". The latter one is shorter and should work just as well. Are you able to access any other session attributes?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too late...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!