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 8231929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:39:30+00:00 2026-06-07T17:39:30+00:00

Can I create a xml file using jsp coding and store it into a

  • 0

Can I create a xml file using jsp coding and store it into a local disk with the specified name we giving.
The xml file structure like this

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<questions>
<question category="something"/>
</questions>

If is this possible please give coding for that.

  • 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-07T17:39:31+00:00Added an answer on June 7, 2026 at 5:39 pm
    <%@page import="java.io.*,org.w3c.dom.*,javax.xml.parsers.*,javax.xml.transform.*, javax.xml.transform.dom.*,javax.xml.transform.stream.*"%>  
    <%!
    public void createXml(String graph) throws Exception{
    try{
        String str="dinesh";
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = builderFactory.newDocumentBuilder();
        Document doc = docBuilder.newDocument();
        // questionset elements
        Element rootElement = doc.createElement("questionset");
        doc.appendChild(rootElement);
        // question elements
        Element question = doc.createElement("question");
        rootElement.appendChild(question);
        // set attribute to question element
        Attr attr = doc.createAttribute("category");
        attr.setValue("graph");
        question.setAttributeNode(attr);
        // write the content into xml file        
    
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();
    
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    
        StringWriter sw = new StringWriter();
        StreamResult result = new StreamResult(sw);
        DOMSource source = new DOMSource(doc);
        transformer.transform(source, result);
        String xmlString = sw.toString();
    
        File file=new File("C:xml/"+str+".xml");
        BufferedWriter bw = new BufferedWriter(new FileWriter(file));
        bw.write(xmlString);
        bw.flush();
        bw.close();
    }
    catch(Exception e)
    {
    System.out.println(e);
    }   
    }
    %>
    <% 
    String graph=request.getParameter("graph");
    createXml(graph);
    %>
    

    save the above coding as any jsp page eg. new.jsp

    Change the name of the file str=”want u want”
    and also change the attribute attr.setValue("want u want");

    U can also change the local disk folder where the file want to save

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we create a new xml file using the jsp coding anyone help me
Can you create a List in a Spring application-context.xml file without using the <list>
How can I create xml file with this format using c#? <?xml version=1.0 encoding=utf-8
Can we create a Silverlight Socket Server ONLY using SILVERLIGHT and XML's (NO WCF
How can I create a PagerView dynamically? Without using a xml? Let's say that
Is there a pattern, Xml structure, architecture technique we can use to create simple
i have the following function i wrote to create an XML file using Xerces
I am using an XSL transformation on an xml file to create an xml
I'm having some trouble using XmlReader to read an XML file. I can open
I need to create an XML file using DOM under Eclipse (for Java) and

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.