Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:56:23+00:00 2026-06-11T08:56:23+00:00

I am just seeing if this is feasible and maybe get a small code

  • 0

I am just seeing if this is feasible and maybe get a small code example if possible. Is it possible to make a JSP page that parses an XML file that is stored on the server.

The XML will contain the elements displayed on the page therefore changing the XML can alter the look / layout of the JSP page.

I am not sure how I would format the XML though and call it into the JSP, if anyone knows a resource or whether that is possible it would be a lot of help (I’m not expecting someone to just do something for me ;))

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:56:24+00:00Added an answer on June 11, 2026 at 8:56 am

    Yes, it is possible, though, why do not you use XSLT? if your main aim is transforming, then XSLT will do the job for you without JSP. If not, then your implementation is specific to the Java Server Pages domain, and when you decide to change the server let’s say to PHP, then you will have to reprogram the whole thing.

    If you want an simple example on how to transform an XML data using java, take a look at the following xml stored in ‘data.xml’

    <?xml version='1.0'?>
    <data>
       <row><cell>1</cell><cell>2</cell><cell>3</cell></row>
       <row><cell>4</cell><cell>5</cell><cell>6</cell></row>
       <row><cell>7</cell><cell>8</cell><cell>9</cell></row>
    </data>
    

    you can read this file using XDom, JDom, or what have you. I will use the basic DOM included in java which is not so friendly and lack iterators, indeed not recommended for large XML files.

    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document d = db.parse(new File("./data.xml"));
    out.println("<table border='1'>");
    for(int i=0;i<d.getDocumentElement().getChildNodes().getLength();i++){
        Node row = d.getDocumentElement().getChildNodes().item(i);
        if(!row.getNodeName().equals("row")) continue;
        out.print("\t<tr>");
        for(int j=0;j<row.getChildNodes().getLength();j++){
            Node cell = row.getChildNodes().item(j);
            if(!cell.getNodeName().equals("cell")) continue;    
            out.print("<td>");
            out.print(cell.getTextContent());
            out.print("</td>");
        }
        out.println("</tr>");
    }
    out.println("</table>");
    

    the html output would be:

    <table border='1'>
        <tr><td>1</td><td>2</td><td>3</td></tr>
        <tr><td>4</td><td>5</td><td>6</td></tr>
        <tr><td>7</td><td>8</td><td>9</td></tr>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is a simple problem, but I am just not seeing it :)
I have just a question... I'm seeing this coding style in various php scripts
Hey guys this should be simple, I'm just not seeing it, I would like
Just seeing if anyone knows anything about this. I installed the 4.1.10111 SL security
Was just wondering about DependencyProperties. Usually I'm seeing this kind of coding standard when
I'm seeing this issue . I have a relatively simple ASP.NET page with a
I am seeing this thing in the logcat over and over just wondering what
I've been working on this irc bot, just seeing if I could recreate some
I'm seeing this code as the equivalent of a mathematical permutation. It tries to
I have a problem that I just cannot seem to get my head around,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.