on 05-15-2006 5:22 PM
Hi
File(File adapter)-->XI->J2EE application(HTTP Receiver adapter).
I get an xml file to my J2EE application. In my servlet i have to generate the xml file as it is and display it in a browser. How to generate the xml file using servlet.
Thanks
Hi
please have a look at the test code which generates a static xml code , might be the change reqd here is that the request you are getting is xml which has to be passed to the response object
public class test extends HttpServlet
{
public void doGet
(
HttpServletRequest req, // This provides information sent by the browser
HttpServletResponse res // This is used to send information back to the browser
) throws
ServletException, // General exception that should be thrown if there
// is a unrecoverable error in the Servlet
IOException
{
// Set the MIME type for the information being sent to the browser.
// In this case, we are going to send back HTML
<i> <b> res.setContentType( "text/xml" );</b></i>
// Get a reference to the output stream.
// Anything written to this stream is sent directly to the browser
// (The browser sees this as its input).
ServletOutputStream out = res.getOutputStream();
// The following println statements create an HTML page.
// Notice that the <html></html>, <head></head>, and <body></body>
// tags are all properly formed HTML syntax.
out.println("<?xml version=\"1.0\"?>" );
out.println("<?xml:stylesheet type=\"text/xsl\" href=\"file:///c:/servlets/test.xsl\"?>");
out.println("<persons>");
out.println("<person><firstname>Oren</firstname><lastname>Ben-KiKi</lastname></person>");
out.println("</persons>");
}
}
hope this helps , please mark helpul answers
regards
rajeshkr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh!
I know this, The xml file that i receive from XI is like this:
<ns0:Http_Message_Type_Demo xmlns:ns0="http://abcdemo.com">
<Name>abc</Name>
<RollNo>123</RollNo>
<Address>a/2</Address>
</ns0:Http_Message_Type_Demo>
How to retrieve these values from my servlet request. Once i get those values, then displaying is easy. Its urgent.Please help me!
Hi
please have a look at the sample code , might be this will be of some help to you
http://www.koders.com/java/fid9BE550126BC02C2093881B643D317309B2114FA7.aspx
Hope this helps , please mark points for helpful answers
regards
rajesh kr
Hi,
Its better that you use statndard JAVA APIs for creating and parsing XML files. GO through the following resources,
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
http://www.javaworld.com/channel_content/jw-xml-index.shtml
http://java.sun.com/developer/technicalArticles/J2EE/AJAX/
Hope these helps,
Guru.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.