Returning xml from a struts action to be used by a ajax client
Hello,
I'm having issues with my ajax call on a WAS server. It functions correctly when run locally on tomcat and WSAD servers.
It looks like the response isnt comming back when the ajax call is made.
My java struts action does the following:
String xml = .....
aResponse.setContentType("text/xml");
aResponse.getWriter().write(xml);
aResponse.getWriter().flush();
return null;Is this the correct way to pass back a response?
do I have to set the header? if so, what should it be?
Thanks,
Con.
A JSP is usually easier to construct the XML since you have looping etc. - otherwise OK.
Similar Messages
-
Hi,
I need to provide the XML tags and dynamic content from the APEX Ajax routine - to be used for the Fusioncharts. How can I return XML from the Ajax routine.
Thanks.
AndyAndy,
Seeing how you are doing everything on load, there is really only a few changes you need to make in order for this to happen via ajax.
1. Create an ondemand process which generates only XML named GET_CHART_XML. Something like ...
declare
l_xml VARCHAR2 (32767);
p_region_width VARCHAR2 (10) := '700';--------------------------------------
p_region_height VARCHAR2 (10) := '300';-- not sure what these are here for --
p_chart_debug VARCHAR2 (10) := '0'; --------------------------------------
begin
l_xml := '<graph showNames=''1'' decimalPrecision=''0'' >' ;
for d in (select b.proj_phase, count(*) total
from it_proj_srvc_req a, it_proj_phase b
where a.it_proj_phase_pk = b.it_proj_phase_pk
and a.it_proj_phase_pk not in (10,99)
and exists (select 'x' from it_proj_srvc_req_pers d,
it_proj_srvc_group e
where d.dph_pers_pk = e.mem_pers_pk
and e.adm_pers_pk = :F120_DPH_PERS_PK
and a.it_proj_srvc_req_pk = d.it_proj_srvc_req_pk)
group by b.proj_phase)
loop
if d.proj_phase = 'Current' then
l_xml := l_xml || '<set name=''' || d.proj_phase || ''' value=''' || d.total || ''' isSliced=''1''/>';
else
l_xml := l_xml || '<set name=''' || d.proj_phase || ''' value=''' || d.total || ''' />';
end if;
end loop;
l_xml := l_xml || '</graph>';
htp.p(l_xml);
end;2. Put this JavaScript in the HTMLHeader section of your page.
<script language="JavaScript" src="/i/themes/custom/FusionCharts/FusionChartsFree/JSClass/FusionCharts.js"></script>
<script type="text/javascript">
function renderChart(){
var myChart = new FusionCharts("/i/themes/custom/FusionCharts/FusionChartsFree/Charts/FCF_Pie2D.swf", "ChartId", "250", "100");
var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=GET_CHART_XML',$v('pFlowStepId'));
get.GetAsync(function(){
if(p.readyState == 1){
$x('chartdiv').innerHTML = '<p>Loading Chart...</p>';
}else if(p.readyState == 4){
if(!p.responseText){return false;};
myChart.setDataXML(p.responseText);
myChart.render("chartdiv");
get = null;
</script>3. Lastly create a button with a url target which points to "javascript: renderChart()".
I was not able to actually test this as I do not have access to the java script dependencies for the flash chart. so I apologize if the JS has a typo in there.
Hope this gets you started in the right direction.
Tyson Jouglet -
How can i return object from oracle in my java code using pl/sql procedure?
How can i return object from oracle in my java code using pl/sql procedure?
And How can i returned varios rows fron a pl/sql store procedure
please send me a example....
Thank you
nullyes, i do
But i can't run this examples...
my problem is that i want recive a object from a PL/SQL
//procedure callObject(miObj out MyObject)
in my java code
public static EmployeeObj callObject(Connection lv_con,
String pv_idEmp)
EmployeeObj ret = new EmployeeObj();
try
CallableStatement cstmt =
lv_con.prepareCall("{call admin.callObject(?)}");
cstmt.registerOutParameter(1, OracleTypes.STRUCT); // line ocurr wrong
//registerOutParameter(int parameterIndex, int sqlType,String sql_name)
cstmt.execute();
ret = (EmployeeObj) cstmt.getObject(1);
}//try
catch (SQLException ex)
System.out.println("error SQL");
System.out.println ("\n*** SQLException caught ***\n");
while (ex != null)
System.out.println ("SQLState: " + ex.getSQLState ());
System.out.println ("Message: " + ex.getMessage ());
System.out.println ("Vendor: " + ex.getErrorCode ());
ex = ex.getNextException ();
System.out.println ("");
catch (java.lang.Exception ex)
System.out.println("error Lenguaje");
return ret;
Do you have any idea? -
It appears to be fairly straight-forward to get XML from a SQL query using the XML SQL Utility.
Is it possible to use this utility (or another) to get XML from a cursor variable as well? I would like to generate overloaded get_xml functions in a PL/SQL package that will accept either SQL or a weak type REF CURSOR and return XML.Thanks for the help. Actually, I just bought your book and was getting ready to do some research. This should get me pointed in the right direction.
Does the PL/SQL API lack this functionality? I wasn't sure whether to implement this in PL/SQL or Java, but the decision may be made for me... -
Return XML from MVC WebAPI Web Service
The tutorials to create a web service using MVC WebAPI (frmaework4.5) in VS 2013 is touted as being "very simple" to return JSON or XML.
But then, all you get is JSON. When you want to return a plain ole' string of XML ... there is no clear documentation. I see a bunch of posts where people are referencing the ActionResult method ... which is not in the APIController class... so that implies
to me that I need to roll my own from the Controller class. That doesn't seem right to me.
So ... how does one return an XML string from an MVC WebApi application?
* the list of "questions similar to yours" that this forum presents me either: a) are for ASMX in VS 2008 or b) do not work.
Any direction to some documentation is appreciated.
ThanksHi,
If this issue is related to MVC, you could ask this question in the ASP.NET forum:
http://forums.asp.net. If then, you could get an answer more quickly and professional. Maybe the
WCF, ASMX and other Web Services forum will be better for this issue. Thanks for your cooperation.
Have a nice day,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to log exception from a struts action class
Hi guys,
I am recoding my application to use the strut framework. There's one small thing i wonder is that how i can log an exception arrise in an action class. In my original servlet, wherever an exception arise, i use:
catch(Exception e)
getServletContext().log("User enter an invalid date");
throw e;
}However, when i move this servlet into a action class, the getServletContext method doesnt work anymore. I thought action is a child of httpServlet but since getServletContext is not available in action, then how can i log the error?
Hope to get some help
Message was edited by:
lnthai2002Hi guys,
I am recoding my application to use the strut
framework. There's one small thing i wonder is that
how i can log an exception arrise in an action class.
In my original servlet, wherever an exception arise,
i use:
catch(Exception e)
getServletContext().log("User enter an invalid
valid date");
throw e;
}However, when i move this servlet into a action
class, the getServletContext method doesnt work
anymore. I thought action is a child of httpServlet
but since getServletContext is not available in
action, then how can i log the error?
Hope to get some help
Message was edited by:
lnthai2002Action class is just a POJO and works a handler of your request. ActionServlet invoke your Action class based on the action you call in your URL. When you are usign the Struts why do you need your Original Servel, use the ActionServlet and if required you can extend it and create your own servlet -
Returning XML from CF for xmlHttpRequest
Greetings,
Not sure what I'm doing wrong here, but I can't seem to get
a .cfm page to return the necessary xml for use in my
xmlHttpRequest javascript code. I know the problem doesn't exist
within my javascript code......if I build the URL to connect to and
point it at an actual XML document, all is well.....I get a proper
XML DOM document back and I can do what I want. However, if I point
it at a .cfm page that is generating XML, it doesn't work.
I've tried a few different ways (<cfcontent> etc)of
trying to get CF to return the results of the .cfm page as XML, but
it's not working.
Suggestions?Well, there you go. Turns out there's some slightly
contradictory info in the help for <cfxml>. In the main help
for the <cfxml> tag, there's no mention of the fact that you
should not use the standard <?xml version="1.0" etc> xml
processing directive when you're using that tag. It is, however,
mentioned on one of the associated help pages. So, now that I've
removed the directive, all is well. -
How to create a savepoint in "BC4J transaction" from a struts Action
Hello,
I need to create a kind of savepoint in a transaction object in BC4J
[ BC4JContext context = BC4JContext.getContext(request);
context.getApplicationModule().getTransaction()."savepoint()" ]
but it seems to me that it doesn't exist!!
How can I do this.
Thanks for help
MehdiMehdi:
BC4J does not support creation of savepoints in its transaction object. Savepoint support is quite tricky in that if we were to support it... If the transaction is rolled back to the SP, we would have to sync the cache back to the state when the SP was taken. And, this can be quite an expensive operation.
Thanks.
Sung -
Ciao all,
Seems the funcion is not available anymore in Lion. I used to slide 2 fingers on the trackpad in Snow Leopard.
Thanks for your replay...and happy holidays
Oricap10Welcome to the Apple Support Communities
I think that something was damaged when you upgraded OS X. This can happen, and it looks like it happened to you. In your case, I recommend you to make a backup and reinstall Mountain Lion erasing the disk:
1. Press Command and R keys while your Mac is starting, and open Disk Utility.
2. Select Macintosh HD in the sidebar, go to Erase tab and erase the disk.
3. Close Disk Utility and reinstall OS X. After installing OS X, restore your files manually and reinstall the applications
If this doesn't work, you can install Snow Leopard again:
1. Insert the Snow Leopard disc and press C key while your Mac is starting.
2. When the disc has started, open Utilities menu > Disk Utility, select the hard disk at the top of the sidebar, go to Erase tab and erase the disk.
3. Close Disk Utility and install Mac OS X. After installing, open > Software Update to install the most recent version -
Trouble accessing dynamic XML from API with a CFC
Please see my example at
http://67.199.18.39/test.html
and view source (to big to post here). I am returning XML from a
dynamic call to an API through a ColdFusion CFC.
Search for something generic like Dog. Click Go. I display
the XML for you to view. I have tried many different XMLList
dataproviders but can't get anything to work.
Can someone point out the "errors" of my ways?
Thanks.Turns out it was a namespace issue. I found the answer from a
Bruce Phillips tutorial at
http://www.brucephillips.name/blog/index.cfm/2006/12/5/Processing-XML-in-Flex-20-Using-The -For-Each-Statement-And-The-Descendent-Accessor--Operator
I had to add:
private namespace yahooNS = "urn:yahoo:prods";
use namespace yahooNS; -
Calling StroreProcedure contain XML as Input and store proce return XML as out-BizTalk
I have a requirement in BizTalk that
- I will receive XML from Source and i need to submit this XML data in SQL storeprocedure as a parameters and submit data
Ex: My_SP(myXML xml Input,myXML1 xml OUT)
Could you please help me how to call storeprocedure and submit XML and how to retrieve XML from SP.One of the way is to return xml from stored procedure instead of getting a typed schema
You can have xml auto defined at stored procedure something like below stored procedure.
SELECT [Employee_ID] ,[Name] ,[DOJ] ,[Designation] ,[Job_Description] ,cast([Rating] as varchar(100)) as Rating ,[Salary] ,[Last_Modified] ,[Status] ,[Address]
FROM [Adapt_Doc].[dbo].[Employee] for xml auto, xmlschema
After that you can directly assign the message to the typed schema something like below
MessageTypedSQL=MessageUntypedSQl;
For reference you can look into below MSDN articles
SQL and XML: Use XML to Invoke and Return Stored Procedures
Executing Stored Procedures Having a FOR XML Clause
Thanks
Abhishek -
JDeveloper and PL/SQL queries which return XML
Hi,
I need to deploy WS with JDeveloper. I have an Oracle9i database which I query with PL/SQL. How can I return XML from my PL/SQL queries? I know I can use SQLX to return XML datatypes, but JDeveloper doesn't seem to be compatible. There is also XSQL, but I don't think JDeveloper allows you to publish this as a web service.
Any help would be greatly appreciated!!! Thanks!!!!The following function should work for what you are trying to do.
htp.p(htf.escape_sc(:P1_ITEM));To escape columns from the database just include it in your select statement:
SELECT htf.escape_sc(COLUMN_NAME) alias
FROM TABLETo escape items on your apex page:
INSERT INTO table
(COLUMN_NAME)
VALUES(htf.escape_sc(:P1_ITEM))Good Luck,
Tyson
Edited by: Tyson Jouglet on Nov 25, 2008 4:12 PM -
Forwarding struts action onto servlet....
...that delivers a file back to the client. I have an action that forwards onto a servlet that serves a PDF - the servlet works fine when accessed on its own, but when it is called from the struts action I get the browser download box appear but with the filename of the struts action, ie. 'MyAction.do' and not file type set.
Has anyone tried this before and had any success?
Thanks.Thanks, got that in though...
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment;filename="+outputFilename);
It seems as if struts is controlling the output to a certain extent (e.g. the filename for download is 'Action.do' rather than my servlet response) even though I've forwarded onto a servlet where I set the above http response headers. -
Command to Export project as Final Cut Pro XML from jsx script
Hi All,
Can somebody get me the command to export the project as final cut pro xml from jsx script.
I was using the extension builder script earlier for cs6 panel development, so we were using pjct.exportFinalCutProXML("pathname");
Now I am working for panel in Premiere CC so working on HTML 5 panel and qe dom scripting(.jsx).
In some jsx examples i got there is script to export sequence as final cut pro xml but cannot get the code for project export.
project.activeSequence.exportAsFinalCutProXML(entire_out_path);
Also please let me know if there are any kind of reference available about all the functions and properties in the pe dom scripting for premiere pro cc.
I am using premiere pro cc 7.1, windows 7, Eclipse Kepler.
Thanks in advance,
Anoop NRWhen you reimport the exported project XML to FCP, do you get the full project or just the single bin/sequence? If you get the full project then it sounds like you need Premiere help, not FCP help ... have you tried asking on the Adobe forums? If you only get the single bin/sequence then it seems you might have inadvertently selected those prior to creating the project export. Try making sure that your FCP Browser window is active and that you have not selected anything within that window prior to using the File > Export > XML command. If that still causes issue then you might try using an earlier FCP XML version.
Hope it helps
Andy -
XQUERY / XMLTABLE Syntax to read and XML from a Windows local drive?
Hi,
Would someone post an example of the syntax to read a text file containing XML from the local Windows disk drive using xquery/xmltable syntax?
Thanks,
VictorDoes the following help...
SQL> conn test/test
Connected.
SQL> -- The test user has the DBA role...
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
5 rows selected.
/* The content of the data.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<ID>0</ID>
<INFO>
<INFO_ID>0</INFO_ID>
<INFO_CONTENT>Text</INFO_CONTENT>
</INFO>
</ROOT>
SQL> drop directory xmlstore;
Directory dropped.
SQL> -- the directory is on a Windows system...
SQL> create directory xmlstore as 'E:\temp';
Directory created.
SQL> create table test
2 (xmldata xmltype);
Table created.
SQL> INSERT into test
2 VALUES
3 (XMLTYPE(bfilename('XMLSTORE','data.xml'),NLS_CHARSET_ID('AL32UTF8')));
1 row created.
SQL> set long 100000000
SQL> select * from test;
XMLDATA
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<ID>0</ID>
<INFO>
<INFO_ID>0</INFO_ID>
<INFO_CONTENT>Text</INFO_CONTENT>
</INFO>
</ROOT>
1 row selected.
SQL> select XMLTYPE('<ROOT><ID>0</ID><INFO><INFO_ID>0</INFO_ID><INFO_CONTENT>Text</INFO_CONTENT></INFO></ROOT>') as "XDATA"
2 from dual;
XDATA
<ROOT><ID>0</ID><INFO><INFO_ID>0</INFO_ID><INFO_CONTENT>Text</INFO_CONTENT></INFO></ROOT>
1 row selected.
SQL> select XMLTYPE(bfilename('XMLSTORE','data.xml'),NLS_CHARSET_ID('AL32UTF8')) as "XDATA"
2 from dual;
ERROR:
ORA-21500: internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]
no rows selected
SQL> select extract((XMLTYPE(bfilename('XMLSTORE','data.xml'),NLS_CHARSET_ID('AL32UTF8'))),'*') as "XDATA"
2 from dual;
XDATA
<ROOT><ID>0</ID><INFO><INFO_ID>0</INFO_ID><INFO_CONTENT>Text</INFO_CONTENT></INFO></ROOT>
1 row selected.
SQL> select xdata
2 from (XMLTABLE('*'
3 PASSING (XMLTYPE(bfilename('XMLSTORE','data.xml'),NLS_CHARSET_ID('AL32UTF8')))
4 COLUMNS xdata xmltype PATH '/*'
5 )
6 )
7 ;
XDATA
<ROOT><ID>0</ID><INFO><INFO_ID>0</INFO_ID><INFO_CONTENT>Text</INFO_CONTENT></INFO></ROOT>
1 row selected.
Maybe you are looking for
-
hi i have code of proxy server.It is not working proper.When i run these code on http://localhost:8080 then it is showing Ip .It is not showing Url .This is a link http://www.cs.technion.ac.il/Labs/Lccn/projects/spring97/project9/ Help me Plz
-
Safari and Mail won't open in Snow Leopard
Any else having this VERY frustrating problem of Safari and Mail not opening. I've installed Snow Leopard and downloaded and installed the 10.6.1 update. Then when I try to open Safari, it says, "You can't use this version of the application Safari w
-
Files recieved being saved in Media Cache
Hey, my friend has been sending me pictures for some time now but over the past 2 days something has changed. Originally they were saved in the recieved files folder and full size, Now they are saved in the Media cache folder and at a lower resolutio
-
A Matrix Output for some enthusiastic students
Hi folks, Greetings. I am trying to create a Matrix Output for some Students who have decided to take Music and/or Sports or neither. I am hoping to break it down by Age and Gender and Interest (Music/Sports). Any help is greatly appreciated! Thanks
-
Excel sparklines disappear when saving the file.
Sparklines that I created in Excel 2011 disappear after saving them and reopening the document. I tried saving it in .xlsx and still nothing. Does anyone have a suggestion to fix this problem?