Create XML using JSP
I am trying to create and send an XML file back to browser where XSL will be
applied. I am using wl6.0 sp2
I tried like this
<%@ page contentType="text/xml" %>
<%
out.println("<?xml version=\"1.0\"?>") ;
out.println("<books>");
out.println("<title>") ;
out.println("XML Programming") ;
out.println("</title>") ;
out.println("</books>") ;
%>
But the browser is blank.
Thanks
shaikjava
Also, valid XML documents have no whitespace before the <?xml ...?>
declaration.
Sam
"Cameron Purdy" <[email protected]> wrote in message
news:[email protected]...
> There are lots of reasons why the browser could be blank. Judging from the
> JSP you provided below, I could not even begin to guess at what you are
> doing to prevent the browser from working.
>
> > <%
> > out.println("<?xml version=\"1.0\"?>") ;
> > out.println("<books>");
> > out.println("<title>") ;
> > out.println("XML Programming") ;
> > out.println("</title>") ;
> > out.println("</books>") ;
> > %>
>
> Do you mean you did all that when you could have just:
>
> <?xml version="1.0"?>
> <books>
> <title>
> XML Programming
> </title>
> </books>
>
> That is what JSPs are for, after all!!! Don't put markup language inside
> code inside a JSP!!! You're going to give someone a friggin heart attack.
>
> Remember:
> servlets = code
> jsps = raw content
>
> You can put content in servlets by embedding it in the code. You can put
> code in jsps by embedding it in the content.
>
> Peace,
>
> --
> Cameron Purdy
> Tangosol Inc.
> << Tangosol Server: How Weblogic applications are customized >>
> << Download now from http://www.tangosol.com/download.jsp >>
>
>
> "chand" <[email protected]> wrote in message
> news:[email protected]...
> > I am trying to create and send an XML file back to browser where XSL
will
> be
> > applied. I am using wl6.0 sp2
> >
> > I tried like this
> >
> > <%@ page contentType="text/xml" %>
> >
> > <%
> > out.println("<?xml version=\"1.0\"?>") ;
> > out.println("<books>");
> > out.println("<title>") ;
> > out.println("XML Programming") ;
> > out.println("</title>") ;
> > out.println("</books>") ;
> > %>
> >
> > But the browser is blank.
> >
> > Thanks
> > shaikjava
> >
> >
> >
> >
> >
> >
> >
>
>
Similar Messages
-
Hi I want to create a xml using JSP For eg I want to create a report
and I want to take all the data required for the report from the user
and want to put all the information in a session and whenever a user
wants to see the html output I should be able to parse the xml file
and show it to user.
I know it is doable but I am confused about storing the data in
session and concerting that data into XML file any help would be
great.
Thanks,
Preeti
Sounds like you might want to look at XML data binding. Something like JAXB
or Castor can create an object that can be turned into XML by merely calling
a single method and probably streamed to Xalan or whatever to create HTML.
However, don't quote me on this - I am having enough troubles with trying to
get the compiled Objects to be as I wish. Basically, they both take your
DTD with an extra file that defines the types to be used in the classes -
i.e. instead of string int might be used - and which tags to turn into
classes and general information such as this about the output of your
classes. You then simply call Unmarshal (for both castor and JAXB) and it
loads the file from the selected input stream into the created object, you
edit the object, what ever - store it on the server... and call Marshal to
get back the xml... as this is all using streams it could be passed to Xalan
for processing i think...
Hope I've helped, and answered your question a little!
"Preeti Sikri" <[email protected]> wrote in message
news:[email protected]...
> Hi I want to create a xml using JSP For eg I want to create a report
> and I want to take all the data required for the report from the user
> and want to put all the information in a session and whenever a user
> wants to see the html output I should be able to parse the xml file
> and show it to user.
>
> I know it is doable but I am confused about storing the data in
> session and concerting that data into XML file any help would be
> great.
>
> Thanks,
> Preeti
-
How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
Hi,
I do generate XML-Files by using DBMS_XMLGEN with output by UTL_FILE
but it seems, the xml-Datafile I get on end is not really UTF-8 encoding
( f.ex. cannot verifying it correct in xmlspy )
my dbms is
NLS_CHARACTERSET = WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_RDBMS_VERSION = 10.2.0.1.0
I do generate it in this matter :
declare
xmldoc CLOB;
ctx number ;
utl_file.file_type;
begin
-- generate fom xml-view :
ctx := DBMS_XMLGEN.newContext('select xml from xml_View');
DBMS_XMLGEN.setRowSetTag(ctx, null);
DBMS_XMLGEN.setRowTag(ctx, null );
DBMS_XMLGEN.SETCONVERTSPECIALCHARS(ctx,TRUE);
-- create xml-file:
xmldoc := DBMS_XMLGEN.getXML(ctx);
-- put data to host-file:
vblob_len := DBMS_LOB.getlength(xmldoc);
DBMS_LOB.READ (xmldoc, vblob_len, 1, vBuffer);
bHandle := utl_file.fopen(vPATH,vFileName,'W',32767);
UTL_FILE.put_line(bHandle, vbuffer, FALSE);
UTL_FILE.fclose(bHandle);
end ;
maybe while work UTL_FILE there is a change the encoding ?
How can this solved ?
Thank you
Norbert
Edited by: astramare on Feb 11, 2009 12:39 PM with database charsetsMarco,
I tryed to work with dbms_xslprocessor.clob2file,
that works good,
but what is in this matter with encoding UTF-8 ?
in my understandig, the xmltyp created should be UTF8 (16),
but when open the xml-file in xmlSpy as UTF-8,
it is not well ( german caracter like Ä, Ö .. ):
my dbms is
NLS_CHARACTERSET = WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_RDBMS_VERSION = 10.2.0.1.0
-- test:
create table nh_test ( s0 number, s1 varchar2(20) ) ;
insert into nh_test (select 1,'hallo' from dual );
insert into nh_test (select 2,'straße' from dual );
insert into nh_test (select 3,'mäckie' from dual );
insert into nh_test (select 4,'euro_€' from dual );
commit;
select * from nh_test ;
S0 S1
1 hallo
1 hallo
2 straße
3 mäckie
4 euro_€
declare
rc sys_refcursor;
begin
open rc FOR SELECT * FROM ( SELECT s0,s1 from nh_test );
dbms_xslprocessor.clob2file( xmltype( rc ).getclobval( ) , 'XML_EXPORT_DIR','my_xml_file.xml');
end;
( its the same when using output with DBMS_XMLDOM.WRITETOFILE )
open in xmlSpy is:
<?xml version="1.0"?>
<ROWSET>
<ROW>
<S0>1</S0>
<S1>hallo</S1>
</ROW>
<ROW>
<S0>2</S0>
<S1>straޥ</S1>
</ROW>
<ROW>
<S0>3</S0>
<S1>m㢫ie</S1>
</ROW>
<ROW>
<S0>4</S0>
<S1>euro_</S1>
</ROW>
</ROWSET>
regards
Norbert -
How do i Create charts using JSP/Servlet & Database
I have to create charts which shows the graph of stock exchange.
i have a database that keeps the data for creating charts.
But i did not know how to create charts using jsp-servlet.
Any Example might help me to go forward.
Any help will be really appreciated.
Please Advice me.JFreeChart - You can generate the charts then convert them to image formats (PNG and JPEG) all using the JFreeChart API
http://www.jfree.org/jfreechart/ -
XMLDataSet and Dynamic XML using JSP
I am trying to use the XMLDataSet function to call a jsp page
instead of an xml file. The jsp page fetches records out of a db
and creates xml to return to the spry function. Nothing seems to be
returned, and blank spry data region on page.
If i supply a xml file to the function it works correctly.
I adapted the ASP/PHP samples from XMLExport demo. Code as
follows:- If i run 2nd jsp directly, the browser shows the xml as
expected.
--- TEST.JSP ---
<script type="text/javascript">
Spry.Data.Region.debug=true;
var dsPeople = new Spry.Data.XMLDataSet("transtoxml.jsp",
"company/person");
</script>
--- transtoxml.jsp ---
<%@ page language="java"
import="java.sql.*, java.io.*, java.util.*,
com.Ostermiller.util.*"
errorPage="" %>
<%@ include file="globals.jsp" %>
<%
String SQL="";
Statement sTransaction;
ResultSet rTransaction;
try
Class.forName(className);
con =
java.sql.DriverManager.getConnection(connectionURL,userName,password);
}catch(Exception e){
out.print(e.toString());
out.print("Error connecting to database " + connectionURL);
SQL ="SELECT ";
SQL+="[ID], ";
SQL+="[DocumentNo]";
SQL+="FROM TRX_TRANSACTION_MAPPING";
sTransaction = con.createStatement();
try {
rTransaction = sTransaction.executeQuery(SQL);
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("pragma","no-cache");
%>
<?xml version='1.0' encoding='iso-8859-1'?>
<company>
<% while(rTransaction.next()) { %>
<person>
<id><%=(rTransaction.getString("ID"))%></id>
</person>
<% } %>
</company>
<%
response.flushBuffer();
sTransaction.close();
} catch (SQLException e) {
out.print(e);
%>This is the xml output the jsp gives when run directly:- Cut
n pasted from browser. There does appear to be an error, because
the spry:state="error" div is being displayed. If i paste the
following into a file all is ok, any ideas anyone.
regards
sm@rt
<?xml version="1.0" encoding="iso-8859-1" ?>
- <company>
- <person>
<id>117</id>
</person>
- <person>
<id>118</id>
</person>
- <person>
<id>119</id>
</person>
- <person>
<id>120</id>
</person>
- <person>
<id>121</id>
</person>
- <person>
<id>122</id>
</person>
- <person>
<id>123</id>
</person>
- <person>
<id>124</id>
</person>
- <person>
<id>125</id>
</person>
- <person>
<id>126</id>
</person>
- <person>
<id>127</id>
</person>
- <person>
<id>128</id>
</person>
- <person>
<id>129</id>
</person>
- <person>
<id>130</id>
</person>
- <person>
<id>131</id>
</person>
- <person>
<id>132</id>
</person>
- <person>
<id>133</id>
</person>
- <person>
<id>134</id>
</person>
- <person>
<id>135</id>
</person>
- <person>
<id>136</id>
</person>
- <person>
<id>137</id>
</person>
- <person>
<id>138</id>
</person>
- <person>
<id>139</id>
</person>
- <person>
<id>141</id>
</person>
</company> -
hi,
i want to know if the following is possible using EJB and XML.
using HTML/javascript, a form has been created. now the user makes selections using the form. i want to create a XML file that encapsulates the user selections ie this XML file should contain the selections made by the user. this XML file should also automatically change whenever the user makes new selections on the HTML form.
someone suggested me that Beans are the best option to use. can u guide me on how to proceed using Beans.
thanks in advance.Why not use a JSP? Much quicker.
(When someone suggested you use Beans, I doubt they meant Enterprise Beans - cf. SledgeHammer vs Nut). -
How to send/receive XML using JSP
Hi,
I'm new to all this JSP/XML stuff so apologies if this is trivial.
I'm trying to send an XML file via HTTP POST using JSP. Anyone know how to do this?
Once the XML has been sent, how do you use JSP to request the XML file? I've figured out how to parse it already.
Also, is it possible to call xsql directly within JSP?
Thanks!I'm trying to send an XML file via HTTP POST using JSP. Anyone know how to do this?The question is, does anybody understand what you mean by this. Let me take a guess. You want to upload an XML file to a server. If this guess is right, then the answer is don't use JSP to do that. JSP is for generating output to be sent to a client. Use a servlet to handle an upload. And you don't need to write it yourself, there are already several file-upload servlets available on the web.
Second guess: you have a POST request that asks your server to send an XML file back to the client. If it's a static XML file you don't need a JSP or a servlet or anything, just let your web server handle it just like any other static file. If it's dynamically generated then there's an answer worth giving, but I doubt that this is your question. But if it is, let us know. -
Create XML using Data Templates
Is anyone familiar will a tool, other than oracle that will create XML from data template definitions.
I trying to understand if the data template definitions are an Oracle specific tool that only Oracle can use to generate XML files.
If this is specific to Oracle, is there an easier way to use the data templates to generate XML without registering them in the concurrent manager, XMLP Admin, and then executing the concurrent process?
I'm looking for a shortcut to testing these files without having to register everything.Why not using XML Publisher Standalone aka Enterprise 5.6.2 ?
There you can generate the XML based on data templates without registering anything. The installation is quite easy.
Juergen -
Hi,
My company just bought a software, which this s/w will generate a HTML file with the XML tags and data inside it.
I will need to read the XML tags and data inside the HTML file using JSP.
Does anyone know how to do this?
Please help mi!!Thanks!http://java.sun.com/webservices/docs/1.1/tutorial/doc/index.html
-
Creating XML using JCA functionality
dear friends,
I am working on connection of EP to R3 using JCO and JCA architecture.
Using JCO, i could able to create XML file
i.e.,
JCO.Table sales_orders =function.getTableParameterList().getTable("KOMV");
sales_orders.writeXML("F:
usr
crpts
" + request.getUser().getUniqueName() + ".xml");
In the same manner i would like to create XML file using JCA functionality. But i did't found any functionality in any way as my knowledge.
can anybody help me out this
Secondly,
is it possible to create XML file with in the par path?
like instead of desktop F:
usr
crpts
path i would like to use like dist/xml
suggestion required.
Kanthadear friends,
I am working on connection of EP to R3 using JCO and JCA architecture.
Using JCO, i could able to create XML file
i.e.,
JCO.Table sales_orders =function.getTableParameterList().getTable("KOMV");
sales_orders.writeXML("F:
usr
crpts
" + request.getUser().getUniqueName() + ".xml");
In the same manner i would like to create XML file using JCA functionality. But i did't found any functionality in any way as my knowledge.
can anybody help me out this
Secondly,
is it possible to create XML file with in the par path?
like instead of desktop F:
usr
crpts
path i would like to use like dist/xml
suggestion required.
Kantha -
Dynamically creating XML using Sap-xMII Colum and Row Action Block
Hi,
I am trying to create a xMII-format XML using IlluminatorDocument Action Block.
My problem statement is during run time I am required to create columns on the fly.which I have done using xMII Colum Action block.but now I am required to assing values to these dynamically created columns.I have tried using Data Item and Row action block but am not sucessful in doing so.Can anyone help in creating this xml Dynamically.
The steps that I have followed is
defined
tagquery action block and defined tagquery
blank Illuminator Document Action block
put a repeater on result of tag query
set a counter
updated the counter
used column action block and mapped the column name i.e IlluminatorColumn_0.Name------"test"&Local.count
my column output looks like
Rowsets DateCreated="2007-03-27T12:59:39" EndDate="2007-03-27T11:42:40" StartDate="2007-03-27T11:42:40" Version="11.5.0">
<Rowset>
<Columns>
<Column Description="" MaxRange="100" MinRange="0" Name="test1" SQLDataType="1" SourceColumn="test1"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test2" SQLDataType="1" SourceColumn="test2"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test3" SQLDataType="1" SourceColumn="test3"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test4" SQLDataType="1" SourceColumn="test4"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test5" SQLDataType="1" SourceColumn="test5"/>
</Columns>
</Rowset>
</Rowsets>
after this action block i want to assign values to each column i.e
<Row/>
<Row/>
<Row/>
<Row/>
<Row/>
i.e erach row tags should be filled with columntag and value
but i am not able to achieve the same
Can anyone help me doing thisAfter adding IllumColum Action block I have created 5 columns dynamically
but now I am unable to add row.
currently for everycolumn created it is giving one row without any column node
the configurations that I have done in Data Item Action Block is
In My Link Editor
IlluminatorColumn_0.Name----
>IlluminatorDataItem_0.Name
hardcoded the value i.e 20----
>IlluminatorDataItem_0.Value
IlluminatorDocument_0.Output----
>IlluminatorDataItem_0.IlluminatorDocument
current resultset I am getting is
<?xml version="1.0" encoding="UTF-8"?>
<Rowsets DateCreated="2007-03-27T12:59:39" EndDate="2007-03-27T11:42:40" StartDate="2007-03-27T11:42:40" Version="11.5.0">
<Rowset>
<Columns>
<Column Description="" MaxRange="100" MinRange="0" Name="test1" SQLDataType="1" SourceColumn="test1"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test2" SQLDataType="1" SourceColumn="test2"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test3" SQLDataType="1" SourceColumn="test3"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test4" SQLDataType="1" SourceColumn="test4"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test5" SQLDataType="1" SourceColumn="test5"/>
</Columns>
<Row/>
<Row/>
<Row/>
<Row/>
<Row/>
</Rowset>
</Rowsets> -
How can I send request to the server through XML using JSP
How can I send XML request to the server using JSP and servlets
Ajax may be the one way.
-
Hello,
I want to creat XML document using Dom and XPath, as per my knowledge goes I can't create it using XPath {I may b wrong, if I am then pls tell me know :-) }.
If there doesn't exists any thing like this I am thinkin of wrapping a class {say its XPathProcesserDom} which takes the XPath querry and internaly creates XML Document and returns on request. Is this a good idea :-)
waiting for comments :-)....
thanks and regards,
MaheshPujariHi Piyush
I don't see how you can create a XML document via xpath!?!? xpath it's only used to reference data in an XML document...
Chris -
Create XML using data from Oracle
Other than using OracleXMLQuery, how do I create an XML file from the data from a table in Oracle?
Rgds,
SeeteshVetsrini:
Thanks for your response. I no longer can receive email at [email protected], because I am at a different company now. So please post directly to this forum so I can receive my messages.
I would imagine that "look ahead" is a feature needed by many applications, since the heading of a document may depend on the data within. In my case, we have a Pack Slip that we want the bold heading title to change if the word "FAX" is inside the body of the document. Instead of saying "Pack Slip", it would say "Fax Pack Slip".
Any hints would be greatly appreciated.
Regards,
Rich Locus -
I am trying to create two frames in my JSP page . However it just displays a blank page on execution.
I am using following code to create frames:
<hbj:content id="myContext" >
<hbj:document>
<hbj:documentHead>
<frameset cols="100,*" border=1 frameborder="1">
<frame name="frame1"
src ="http://www.yahoo.com">
<frame name="frame2"
src= "http://www.google.com">
</frameset>
<hbj:documentHead>
</hbj:document>
</hbj:content>
ThanksNeeti,
Just get rid of JSP tags and put the frameset html on jsp page. It should work without JSP tags.
<html>
<frameset cols="100,*" border=1 frameborder="1">
<frame name="frame1"
src ="http://www.yahoo.com">
<frame name="frame2"
src= "http://www.google.com">
</frameset>
</html>
Message was edited by: Prakash Singh
Maybe you are looking for
-
Copy a purchasing inforecord from one supplier to another.
When a supplier changes his TVA-number, or when there is a take-over by another company, the supplier number changes,. We want to transfer all inforecords from the old supplier to the new supplier, because all info remains the same. The Tcode MEMASS
-
Movie won't play on IE9. Works fine on other browsers
Movie plays in all browsers except IE9 Feb 11, 2013 3:05 PM Please go to this site: http://www.shop.com/Isotonix+reg+OPC+3+reg+-561800349-p+.xhtml You will see "View Product Video" to the left of "Ship Free". When I click that link in ALL browsers (
-
Can i set apps to always launch in ful screen (like Safari)
can i set apps to always launch in ful screen (like Safari)
-
How do I check to see WHAT'S using up the most storage.
I have a 500gb Drive but only 11 free. Wanted the best way to see what's using up space. I can randomly hit command I on folders and check that way, but was wondering if there was a way to see a document or spreadsheet, or pie chart of everything t
-
Sending uploaded file to the approver using GP Process
Hai all, i my project i need to send the resource files for approver ... in my application i have created three actions under one sequencial block ..i need to send the user uploaded files to the three approvers .....