Generating XML Document Using JSP
JSP, one of the important and powerful technologies for building web application and can be explained as a combination of java (inside JSP tags) and HTML tags in such a way which leads to the creation of dynamic HTML pages.
to the creation of dynamic HTML content, JSP can also be used for generating
dynamic XML document. This is done by sending XML tags in the form of
strings as a output of JSP page. You will understand better on how to
accomplish this with the help of following example:
As you know the output of a JSP page is the whole content leaving JSP directives and other constructs. This is the reason you have not used any output method for passing the XML tags. It is worth to note here that JSP directives are a type of JSP tags used to perform a specific task in a program and begin with <@. Some commonly used directives are import include etc.
Looking into the above example you can see that here its been used as the JSP directive page and its attribute contentType. Its value is equated to the string text/xml in order to guide the browser (which is going to show the output of JSP) about the type of content.
the default value of contentType is text/html but here as we are generating
an XML document so it is mandatory to set the contentType as text/xml.
So you can easily create an XML using JSP. This method can also be used for creating other markup documents by using JSP.
| All About Different Types of XML Editors | Generating XML Document Using JSP | How to Retrieve an Email Message Using Java Mail API | How to Send an Email Message Using Java Mail API | Transforming XML Data with XSLT | Understanding Basic Components of a JMS Program | Understanding Basic Technology of ebXML | Understanding Deployment Descriptor in Reference with Servlets | Understanding eXtensible Access Control Markup Language (XACML) | Understanding the Design Goals of XML | Understanding XML Common Biometric Format |
Copyright - © 2004 - 2018 - All Rights Reserved.