• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp, xml,Servlets  RSS feed

 
viral patel
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm generating xml inside my jsp page, now i want to send that xml to servlets using that same jsp page.. Can i do that, if i can how. can some one show me example how to do it..
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds turned around. Why not have a servlet request the XML by opening a URL to the JSP?
Or do you mean that your JSP generates XML in addition to writing a HTML page?
Bill
 
Geeta Ramasami
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
1.One way of achieving this is in JSP u save the XML file to some path and in the servlet read the XML file from that path.
2.Else use this approach
In JSP
StringBuffer buff = new StringBuffer();
buff.append("<XML version=1.0>");
buff.append("<NAME>aaa</NAME>");
buff.append("</XML>");
<input type="hidden" name="xml" value = "<%=buff.toString()%>">
Post the JSP request to a servlet
In the servlet
String s = request.getParamter("xml");
Then use it..
Cheers
Geeta
 
Thomas Hubschman
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there,
Geeta's technique is a good one, it's what would do too.
Tom
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!