• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

passing xml on wire

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a jsp page (which is actually an XML file, with some java code scriplets in it).
When a client request through a ejb, in my ejb I will connect to this jsp page, so that it excutes and then I will have to send the input stream from this httpconnection to the client, which is over a wire.
So I need some serializble object as a return value.
I was wondering if anyone could help me out here.
Thanks,
Sony Gam
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what the exact issue is.
I am assuming that you have a InputStream to an XML doc. You need to pass this to some remote object.
Your question is how to do this.
Well, I think you can write this to a String and send the String over.
Do you think that is a feasible/possible solution.
 
sony gam
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ganesh,
thyanks a lot for responding.
I am sorry if I could nnot make myself clear.
Well, here is my jsp page.
<%@ page import="javax.ejb.*,javax.rmi.*,javax.naming.*,examples.entities.entity.*" %>
<Tag1>
<Tag2>
<%
InitialContext ic = new InitialContext();
EntityHome sHome = (EntityHome)PortableRemoteObject.narrow((EntityHome)ic.lookup("server.entities.Entity"),EntityHome.class);
Collection entities = null;
Entity entity;

try
{
entities= sHome.findEntities();
}
catch(Exception ex)
{}
Iterator it = services.iterator();
while (it.hasNext())
{
try
{
entity = (Entity)PortableRemoteObject.narrow(it.next(),Entity.class);%>
<Entity id=<%=String.valueOf(entity.id())%> description=<%=entity.description()%>>
<% }
catch(Exception re)
{
System.out.println("Remote Exception caught in Navigation manager");
}
}

%>
</Tag2>
<Tag1>
As you can see, it is actually a xml page, but using JSP just for the java scriplets in between. (What this code does is queries the database for some values using an Entity bean)
Now I have a client who invokes an ejb bea on my server.
Then in the server code, using a httpurlconnection object I just connect to the url location where the above jsp page is located.
so the java code embedded in the page gets executed and I have the complete xml file, which looks like this:
<Tag1>
<Tag2>
<Entity id="5" Description="xyz"/>
</Tag2>
</Tag1>
Now I have to send the resultant stream to the client as retrun value for the method he invoked earlier.
What I thought I could do is obtain the inputstream object from the httpurlconnection object I previously used. But as the BufferedInputStream is not serializable I can not send it.
so I was wondering if someone could suggest me something, here.
Thanks,
Sony Gam
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!