开发者

how to fetch value in xml file from jsp?

Hey i have a situation in which i need to pass some variable value in jsp to xml file.

for example if i have int a = 10;

and i want to pass value of "a" to xml file which is something like:-

<graph caption='Estimated Renewal Cost' xAxisName='Year' yAxisName='Units (US Dollars)' showNames='1' decimalPrecision='0' formatNumberScale='0'>
    <set name='Backlog' value='19273773' color='AFD开发者_如何学JAVA8F8' />

</graph>

so in i want the value of "a" to be brought at value attribute of set tag in xml.

Actually i'm using fusion charts to generate graph and want to have dynamic graph which may change according to my jsp page. And as far as i know fusion charts only accept data in xml format.

I have no experience with xml.


Your question doesn't make much sense. An XML file is just that: a file. It doesn't contain any executable or interpreted statement.

You probably want to dynamically generate an XML file (or stream), but unless the output generated by the JSP is this XML file (after all, JSPs typically generate (X)HTML, and can be used to generate other kinds of XML documents), it's not really a task that a JSP should do. A servlet is the place where such a task should be done.

If you want to generate an XML document, you have many choices: DOM, JDOM, dom4j, JAXB, or even plain string concatenation (although I would not recommend it, except if all you need to do is generating such a small document with only one dynamic attribute).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜