i have a html or jsp file with the input values ,when i click the submit button it calls a servlet's do post method,so there i need to generate a xml file using some java code, and in that xml file i want to show all the data recieved in request.
Can you share what have you tried and what is not working
The general steps for achieving this would be
1. Read the request
2. Create a file and populate the file based on the request parameters and your business logic
3. Write the file to the response's outputstream
Note: remember to set the content type appropriately
Paul Clapham wrote:You're producing a string containing some XML, but then you say something about a "generated file". I don't see any code which generates a file there.
the file got generated in my local machine and it looks like this
i am reading this file with this code
but it does'nt parse the file, as it through an exception like "input" element must have end tag "input"
Paul Clapham wrote:The error message is exactly correct. You don't have well-formed XML there.
However the code you posted does produce well-formed XML. So the data you posted wasn't produced by the code you posted.
right paul ,i am able to create a xml but with some restrictions. like if use an Element object and then i set the attributes of it, it does produce the well formed tag with xml but without a end tag.
still looking that how can i achieve this. another approach is like i shall read the file as string and then i have to manipulate it by inserting the end tag and then parse.
Nope. If you use those DOM methods to create a representation of your XML in memory, and then use an identity transformation to serialize it to disk, you will get well-formed XML. What you showed was HTML, not well-formed XML. Therefore it was not produced in that way. You should review your code and configuration to find out what is really happening.
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad: