Generating html files from xml file [duplicate] - java

This question already has answers here:
creating html page from xml file
(3 answers)
Closed 8 years ago.
I have a web page where the information of all the users are stored and I am storing the information
of the users in a xml file. COnsider the name of the xml file "abc.xml" when the users to open the
same page say "www.domain.com/abc.html" I neeed to constracut the HTML fetching the data from the xml using
servlets.

A couple of possible (clean) approaches:
deserialize the xml file with XStream or jaxb, feed the deserialized data to a JSP and generate the HTML server side.
use XSLT to have the html rendering done client side.
For me there's no "best" choice between those, it depends on your use case and constraints.

Related

How to seperate servlet web.xml file into 2 or more XML files [duplicate]

This question already has an answer here:
Including files in web.xml
(1 answer)
Closed 7 years ago.
If my web application have too many servlet class and filter, I think put all in the same document is too complex, I want to konw how could I seperate it to 2 or more XML file.
XML allows external entities (other XML files) to be imported. Relevant question here - Can we import XML file into another XML file?.

Dynamically Generate A Form Using an XSD file?

I have a Java file that has XML annotations and I have an XSD file related to it. I want to generate a form at web page using that XSD file (dynamically). If a field is required I will put a mark at form field that shows it is a required field. User will fill fields. I will save it as an XML file and I will validate it against my XSD file. If a non valid situation occurs I will show it to user.
What can I use to achieve my purpose. What do you suggest for my architecture?

Validate file contents based on extension [duplicate]

This question already has answers here:
Validation of files based on their file extensions
(2 answers)
Closed 9 years ago.
I want to validate file contents based on their extension. For example, a user can save a document file (.doc/.docx) as an Excel file (.xls/.xlsx). Before I get the file contents, using Java I need to validate the content type matches with that extension.
Is any one have idea about, please share your points.
There exists projects already to detect the details of a file. The file command on linux can do this for example.
A Java project called Tika might be useful to you, Tika will parse the file(s) specified on the command line and output the extracted text content or metadata to standard output.

Export to excel using JavaScript ? [duplicate]

This question already has answers here:
Generate excel sheet from html tables using jquery
(4 answers)
Closed 9 years ago.
I have table that get data from java code and show that data on web page . Can i export this data in excel format using javascript?
What will be the code for that
Javascript does not interact with file Object. it requires aciveX Object that only IE has available.
you need to export it using different third party library like apache POI
Also you can anyhow use wkhtmltopdf that prints exactly same that will be available on HTML page into pdf

java best way to create and write XML [duplicate]

This question already has answers here:
How to read and write XML files?
(6 answers)
Closed 7 years ago.
We need to write XML files to a zip file. This part of our code is 22%+ of the total processing time so optimizing this will be a big win. We're presently using dom4j to write out to a Document and then using XMLWriter to write the generated Document to the ZipOutputStream.
We need to run on Java 1.4.
The code is written so we do NOT need a DOM. We walk through writing the xml in order so if it can then write immediately to the zip stream, that would work well.
Update: We also use dom4j for XPath queries (where we do read the XML into a DOM). We can have 2 libraries but if there's an alternative that is better for both uses, that would be good too.
But for this specific need, it's pure write it out, in order (ie no DOM needed).
I think StAX produces streamed XML Output: http://stax.codehaus.org/. That would get you out of maintain a DOM in memory for the output XML.

Categories

Resources