How to display XML file(as markup) in jsp page..?

Hi All,
* I have to display the XML file(as markup) in jsp page (Tree Format)....
* My XML file is an java.io.file object , and how to view this XML file on my JSP page...........
Thanks in Advance,
JavaImran

You mean you want to see the XML source?
You need to replace the characters '<' and '&' with corresponding entities '&lt;' and '&amp;'. You can use replaceAll, but do the ampersands first.
Then I suggest you probably want to put them in a <PRE> block.

Similar Messages

  • How to display XML file in java swing

    hi all
    now i do my M.Sc., project on data maining.this time i have one problem,thats i can't display XML file in swing frame.so any one know this plz give me that idea or code.
    Thanks to all.
    RSK

    One way of doing that is to use JDOM...
    u create an xml tree, and then output using XMLOutputter class...it will be displayed in text...im not sure if thats what u want...however, if u do want to represent it visually then u may need to draw a tree...u may use the Graphics2D for that...there are alot of ways to do such thing, and the 2 possibilities arent the best...depends on what u want...elaborate more pls.

  • How to display XML file that XI sent to my j2ee appl?

    Hi,
    In my scenario File->XI->J2EE appl.
    I got XML page cannot be displayed.
    XML document must have a top level element. Error processing resource 'http://localhost:7001/Invoke/DisplayRes'.
    I deployed my .ear file on BEA Weblogic application server9.0
    I found no error when i tested in SXI_MONI and RWB->Message monitor as well.
    This is my servlet code:
    public class DisplayRes extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doPost(request,response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));
         String inputLine;
         StringBuffer sBuf = new StringBuffer();
         PrintWriter out = response.getWriter();
         response.setContentType("text/xml");
         while ((inputLine = brin.readLine()) != null)
             sBuf.append(inputLine);       
             //out.setContentType("text/xml");
             //out.println(sBuf.toString());
             out.write(sBuf.toString());
              brin.close();
             out.flush();
    What went wrong.All helpful answers are highly rewarded.
    Thanks

    Hi
    Can anyone tell me how XI sends messages to applications like J2EE. In REceiver comm channel, I think we specify about the target system like J2EE appl.
    Aadapter Type: HTTP
                   Receiver
    Transport Protocol:  HTTP1.0
    Message Protocol:    XI payload in HTTP body
    Adapter Engine:      Integration Server
    Addressing Type:     URL address
    Target host:         localhost
    Service Number:      7001(Port number of Weblogic appl server--where my J2EE appl is deployed).
    Path     :  /Invoke/DisplayRes/
    Authentication Type:Use Logon Data for SAP System
    Content Type: text/xml
    Username:   xiappluser
    password:   xx
    XML code:   UTF-8
    I suppose XI sends msgs to http://localhost:7001/Invoke/DisplayRes/........
    in this example if am correct?
    Then I have given all tyhe necessary setting but my servlet is not able to display XML msg in browser?
    This is my servlet code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         PrintWriter out = response.getWriter();
         BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));
         String inputLine;
         StringBuffer sBuf = new StringBuffer();
            response.setContentType("text/xml");
         while ((inputLine = brin.readLine()) != null)
             sBuf.append(inputLine);
             out.println("hi");            
                out.println(sBuf.toString());
             brin.close();
             out.flush();
    What went wrong?
    Help me, all helpful answers are highly rewarded.
    Thanks

  • How to display XML file in browser using Servlets?

    Hi My XML file is like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:purchase_order_MT xmlns:ns0="http://filetohttp.com">
    <ORDER_HEADER_IN>
    <purchase_date/>
    <purchase_group/>
    <purchase_org/>
    </ORDER_HEADER_IN>
    <vendor/>
    <ORDER_ITEMS_IN>
    <item>
    <storage_location/>
    <plant/>
    <quantity/>
    <material/>
    </item>
    </ORDER_ITEMS_IN>
    <ORDER_SCHEDULES_IN>
    <item>
    <delivery_date/>
    </item>
    </ORDER_SCHEDULES_IN>
    </ns0:purchase_order_MT>
    My Servlet receives this XML file and it should display the above XML as it is, How to do that?
    Please help me I have posted same question in many forums but i got no proper reply.
    Thanks a lot

    If you only need to display it, consider your HttpServletRequest just as byte stream. :) Just read from ServletInputStream and write it back into ServletOutputStream of HttpServletResponse.
    If you want to process incoming XML, please give some details first, what exactly you want to do. :)

  • How to display XML file as is it is in my browser using servlets???

    I have a question like my servlet receives an XML file in its request object. I just need display the same XML file as it is in my browser. How to do that? Please help me out. I have searched so many blogs, but i did not get right solution.
    My XML file file will be like this:
    <ns0:Http_Message_Type_Demo xmlns:ns0="http://abcdemo.com">
    <Name>A</Name>
    <RollNo>123</RollNo>
    <Address>a2</Address>
    </ns0:Http_Message_Type_Demo>
    Thnks

    You mean you want to see the XML source?
    You need to replace the characters '<' and '&' with corresponding entities '&lt;' and '&amp;'. You can use replaceAll, but do the ampersands first.
    Then I suggest you probably want to put them in a <PRE> block.

  • How to break up a huge XML file and generate serialized JSP pages

    I have a huge xml file, with about 100 <item> nodes.
    I want to process this xml file with pagination and generate jsp pages.
    For example:
    Display items from 0 to 9 on page 1 page1.jsp , 10 to 19 on page2.jsp, and so on...
    Is it possible to generate JSP pages like this?
    I have heard of Velocity but dont know if it will be the right technology for this kind of a job.

    Thank you for your reply, I looked at the display tag library and it looks pretty neat with a lot of features, I could definitely use it in a different situation.
    The xml file size is about 1.35 MB, and the size is unpredictable it could shrink or grow periodically depending on the number of items available.
    I was hoping to create a documentation style (static pages) of the xml feed instead of having 1 jsp with dynamic pages
    I was looking at Anakia : http://jakarta.apache.org/velocity/docs/anakia.html , may be it has features that enable me to create static pages but not very sure.
    I think for now, I will transform the xml with an xsl file and pass the page numbers as input parameters to the xsl file
    null

  • How to display a document content in a JSP page

    Hi friends,
    I am trying to display a document's content in a JSP page after user authentication.For that I mapped a jsp file with extension ".sens" in Content Management SDK manager,and put the file in the directory '/ifs/jsp-bin' of webstarterapp,but it is not working.Please help me to solve the probleb as earliest.
    Regards
    Prasenjit

    under view put a new tag
    <f:view>
    <ui:script url="page.js"/>
    and thats it

  • How to display result in more than one jsp page

    Hi all,
    the result is a very large it will take more than one jsp page in this senario how we will display the result in more than one jsp page.
    Thanks in Advance.

    The magic word is "paging". Look around using this keyword.
    Basically it's all about subquerying, (eventually) caching and sublisting.

  • How to display a variable(non editable)  in JSP page?

    I have this java code in my JSP and I want to print it on the JSP page with a name associated to it so that it can be passed to a Java Bean. How can I do it?
    String user = display.getOwnerName();

    whatever value you want to send it to server side, you have to put it in a "form". You can put it in HTML form input tag , JSP form, Struts form or JSF form.
    for example:
    <form action="getUserProfile.do">
    <input type="text" value="<c:out value='display.ownerName' />" />
    </form>
    kind regards

  • How to open pdf files in FireFox through jsp page?

    hi all,
    i have a problem when i click the link in jsp page. whenever i am clicking the jsp page link it wants to open a pdf file, the pdf file is located in remote system. its working properly in Internet Explorer. but i am opning this in FireFox means its not opening. In firefox url that is not showing the exact path. optionally its showing like that:
    http://172.16.2.21:9090/FMS/source/
    journal/%5C%5C172.16.2.1%5C
    copyediting%5CELS%5C
    Manuscript_Screening%5CMS%5C
    RDTEST%5C02-Process%5C
    RDTEST-D-08-02051.fdf
    and my jsp code whichever working fine in Internet Explorer is :
    <%
    String newpath="\\\\172.16.2.1\\copyediting
    \\ELS
    \\Manuscript_Screening\\MS\\RDTEST\\
    02-Process\\RDTEST-D-08-02051.fdf";
    %>
    <a href="<%=newpath%>" target="dynamic"></a>can any one solve my problem. as soon as possible. thanks in advance.

    hi Edmondo ,
    This is html generated jsp compilation code.
    link1
    can u please give me the solution. thanks in advance......

  • How to display custom names for attributes in JSP pages

    I would like to use custom names for my attributes in Struts JSP table headers.
    For example, if the database table named "Country" has a column CNT_ID and BC4J wizard mapped it into an Entity Object's attribute "CntId" I would like to display it as "Country ID" in my JSP table header.
    Now, I suppose the place to try this is probably in DataEditComponent.jsp, DataQueryComponent.jsp etc., and probably has smthg to do with jbo:AttributeIterate, but I still can't figure how to achieve this...
    I use JDev 9.0.3

    Kresimir,
    It's not clear from your posting whether you've worked out how to do what you want with control hints, so just in case, here's how:
    - In the navigator, select your entity object or your view object
    - In the structure pane, double-click the attribute you want to edit (CntId)
    - In the attribute editor, select the control hints page
    - In the Label Text field, type the text you want to use for your label (Country). Click OK.
    Hope this helps
    Blaise

  • How to make a file downloadable on my JSP page.......

    I want to make a file to be downloadable on my webpage. I have developed a simple lindk to the file. But internet explorer opens that file and don't show option to save it on hard disk. If any can mail me some Servlet solution or applet ( preferably servlet ) I will be very thankfull to him
    My mail address is
    [email protected]
    Please send it to me as soon as early as my M.Sc viva is going to held shortl and I have to add it before that viva.

    Hi,
    generally browsers will ask whether to save it to local drive or open it?, if you click on a link that has link to a file. This you need to set in the browser's options. check your browser's options and set the option to show the dailog box if you click a hyperlink.
    have fun!!
    --raj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to Display XML in a UIWebView?

    Hi everybody. I like how Safari displays XML files and I would like to emulate that functionality in an iPhone UIWebView. However, I just can't get it to look the same when passing a URL to the UIWebView.
    For example, take a simple XML file like http://molottery.com/rss-num.xml. Viewing that in Safari looks okay, but passing that same URL into a UIWebView just shows a blank page.
    I changed the web protocol from http to feed (feed://molottery.com/rss-num.xml) and it launches the page in Safari instead of my UIWebView. Looks good, but it quit my app... :- (
    I noticed that XML files on the iPhone get re-routed through reader.mac.com so I tried appending that to my URL (http://reader.mac.com/mobile/v1/http://molottery.com/rss-num.xml) but that did not work either.
    When I tried URLEncoding the string like Safari does (http://reader.mac.com/mobile/v1/http%3A%2F%2Fmolottery.com%2Frss-num.xml) I get a UIWebView saying that "This Application Is Viewable Only On iPhone".
    So how can I emulate the regular Safari XML functionality inside my UIWebView? I will post my code upon request, if that will help. Any assistance from the Developer Community would be greatly appreciated.
    Thanks!

    You may have better luck in the iPhone dev forums...
    https://devforums.apple.com/community/iphone/web

  • How to retrieve the parameter names from a JSP page ? Urgent Please

    Hello,
    Can anybody tell me how to retrieve the parameter names from the JSP
    page. (without using getParameterNames() method.)
    The problem with the getParameterNames() method is I get the Jumbled output.
    I need it very badly
    With regards
    Ananth R
    email:[email protected]
    [email protected]

    Dear duffymo,
    My primary intention is to convert the JSP form information into a XML file.
    If I do not get the Parameter names in the correct order how can I maintain
    tag order in XML file.
    For ex: (JSP PAGE VIEW)
    Name--
    FirstName
    MiddleName
    LastName
    Address--
    Street1
    Street2
    City
    Country
    &so on
    (XML File to be generated)
    <Name>
    <FirstName>Value</FirstName>
    </Name>
    <Address>
    <street1>value</street1>
    </Address>
    & so on
    If I use getParameterNames() to get all the parameter names(Which form the tag names in the XML file ) the Enumeration object it returns will not be in the same order as the text fields in JSP.From this I can not construct a meaningful XML file.
    order means: Order of entry on the page, from top to bottom
    That's it
    Waiting for your responses

  • How do you display xml file with xlst sheet in jsp

    I have an xml file with accompanying xslt file (and several images that are used in a single directory. If I doubleclick on the xml file, it displays perfectly in my browser - Formatting, images and all!
              The 100 dollar question - How do I duplicate this behavior in a JSP page in WebLogic 8.1 using the code in the xml and the accompanying xslt (formatting) file? I tried simple embedding the xml code in the jsp, but that didn't seem to work. What is the secret?
              Okay, I need to add a bit more information here. I understand that it is really easy to just redirect to the XML file. The issue is really security. I want the XML to be inside a jsp that will only allow validated users to view it.
              Another way to look at the problem would be, can I add a jsp security tag to the xml file? Or how to I add the xml code inside a jsp and keep the path references to the xslt and graphics.
              Hope the added information helps
              Thanks,
              Ken
              Message was edited by: KLee - 20050609 10:25 MST
              [email protected]

    This proved out to be the answer. Thanks for the direction!
              import java.io.File;
              import java.io.IOException;
              import java.io.InputStream;
              import java.io.OutputStream;
              import java.io.FileNotFoundException;
              import java.io.FileOutputStream;
              import javax.servlet.ServletException;
              import javax.servlet.http.HttpServlet;
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.http.HttpServletResponse;
              import javax.xml.transform.Transformer;
              import javax.xml.transform.TransformerConfigurationException;
              import javax.xml.transform.TransformerException;
              import javax.xml.transform.TransformerFactory;
              import javax.xml.transform.stream.StreamResult;
              import javax.xml.transform.stream.StreamSource;
              public class XML_XSLT_Servlet extends HttpServlet {
              protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
                        String xmlfile = req.getParameter("xmlfile"); if (xmlfile==null) xmlfile = "test.xml";
                        String xsltfile = req.getParameter("xsltfile"); if (xsltfile==null) xsltfile = "test.xslt";
                        /* Test if file exists!, or use default file */
                        File f1 = new File(getServletContext().getRealPath("WEB-INF/displayfiles/"), xmlfile);
                        File f2 = new File(getServletContext().getRealPath("WEB-INF/displayfiles/"), xsltfile);
                   if (f1.exists() && f2.exists()) {
                             // System.out.println("Files Found");
                        } else {
                             System.out.println("XML and XSLT Files NOT Found");
                             System.out.println(f1.getPath());
                             System.out.println(f1.getName());
                             xmlfile = "test.xml";
                             xsltfile = "test.xslt";
              InputStream fileXML = getServletContext().getResourceAsStream("WEB-INF/displayfiles/" + xmlfile);
              InputStream fileXSLT = getServletContext().getResourceAsStream("WEB-INF/displayfiles/" + xsltfile);
              OutputStream os = res.getOutputStream();
              TransformerFactory xFactory = TransformerFactory.newInstance();
              StreamSource stylesheet = new StreamSource(fileXSLT);
              Transformer xformer = null;
              try {
              xformer = xFactory.newTransformer(stylesheet);
              } catch (TransformerConfigurationException tfce) {
              tfce.printStackTrace();
              StreamSource input = new StreamSource(fileXML);
              StreamResult output = null;
              try {
              output = new StreamResult(os);
              } catch (Exception e) {
              e.printStackTrace();
              try {
              xformer.transform(input, output);
              } catch (TransformerException xfe) {
              xfe.printStackTrace();
              <pre></pre><pre></pre>

Maybe you are looking for

  • Error message while creating a template.

    when i create the 10 th WBS element in second level and save it,the system gives the error message"Project Number and WBS Number mismatch" But i am not getting this error till 9th WBS element in second level.In project coding mask the project numberi

  • Reading files.

    Beginner here. I have written a dyno data acquisition program in LV 6.0 (WIN XP). It saves the data into a text file. (Several thousand lines, of 6 comma delimited rows. (the row data varies in length) Now I want to read that file and graph it. I am

  • SQL Qurey Problem

    I have produced the below query for the production department to see what orders are due to be despatched in a particular month. Some of our sales orders are split delivery so i have to do this on a line basis. I am wondering whether i can use a case

  • Upgarding to struts 1.3.8

    Hi all, I am quite new to struts and have, perhaps a quite stupid error. Until now a used Struts 1.2.9 (because my IDE had it onboard). Now I want to use some features of the version 1.3.8 and moved to this version that for. But now I have a strange

  • Bridge New keywords are not shown on startup

    Hi, I have some images, (in folder X) which I tagged with NEW keywords I created. When I reopen bridge, these new keywords are not shown by default. In ordert to see the above keyword, in the keyword panned, i have to navigate to folder X. Is this a