Redirecting from a JSP to an XML file

I have an issue that I urgently need to sort out.
I'm running a web application which uses EJB's for the
back-end and JSP's for the front-end.
I have a class that generates an xml file on the system
containing client information. I create a String Object
which holds the filename & retrieve it inside a Servlet to
forward as a HttpServletRequest attribute. Inside the JSP
which retrieves the attribute I then attempt to open the file in a new browser window.
The problem is when it opens, only the xml data is displayed and the file is not rendered using the specified xsl style sheet. My JSP looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
%>
<%@ page import="za.symbiotics.momentum.forms.helper.*"%>
<%
String file = "../" + request.getAttribute("FILE").toString();
%>
<TITLE>Momentum Simplicity</TITLE>
</HEAD>
<BODY onLoad="forward()">
<%
response.setContentType("text/xml");
response.sendRedirect(file);
%>
</BODY
</HTML>
...part of the Servlet...
FormWriter fw = new FormWriter();
String prefix = getServletContext().getRealPath("/");
String file = fw.getFile()
RoleFileName rf = new RoleFileName()
rf.setFilename(file);
req.setAttribute("FILE", file);
Any advice will be appreciated.

u first read the xml file in-memory .Create DOM object .Then apply the XSL on this DOM .
Now take this in-memory DOM and write it on the OutputStream :
ServletOutputStream objOutPutStream = response.getOutputStream();
objOutPutStream.write(objDOM);
objOutPutStream.flush();
objOutPutStream.close();
*********************************************************

Similar Messages

  • Inserting data from  a table  to an XML file

    I want to insert the values from this xml file emp.xml into a table Employees :
    <EMPLOYEES>
    <EMP>
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAME>
    <JOB>CLERK</JOB>
    <HIREDATE>17-DEC-80</HIREDATE>
    <SAL>800</SAL>
    </EMP>
    <EMP>
    <EMPNO>7499</EMPNO>
    <ENAME>ALLEN</ENAME>
    <JOB>SALESMAN</JOB>
    <HIREDATE>20-FEB-81</HIREDATE>
    <SAL>1600</SAL>
    <COMM>300</COMM>
    </EMP>
    <EMP>
    </EMPLOYEES>
    and here is my Employee table in Oracle 9i database
    SQL> DESC EMPLOYEE;
    Name Null? Type
    EMPNO NUMBER
    EMPNAME VARCHAR2(10)
    JOB VARCHAR2(10)
    HIREDATE DATE
    SAL NUMBER
    After getting help from the members i was able to do the insert of data from the xml file to the table..how to do the insert of data from the table to the xml file.
    Regards,
    Renu

    Hello michaels , thank you for the solution, still i am having some problems
    Here is what i have done :
    1.
    SQL> CREATE DIRECTORY my_table_dir AS 'E:\table_files'
    2 ;
    Directory created.
    2.
    SQL> select * from myemp;
    ENAME
    SMITH
    ALLEN
    3.
    This is the content of the existing xml file saved in the directory E:\table_files as emp.xml
    <EMPLOYEES>
    <EMP>JIM</EMP>
    <EMP>RICK</EMP>
    </EMPLOYEES>
    4.
    Now i executed this code :
    declare
    emp_xml xmltype;
    begin
    select sys_xmlagg (column_value, sys.xmlformat ('EMPLOYEES')) emp_xml
    into emp_xml
    from table (xmlsequence (cursor (select *
    from myemp
    where ename in ('SMITH', 'ALLEN')),
    sys.xmlformat ('EMP')
    dbms_xslprocessor.clob2file (emp_xml.getclobval (), 'E:\table_files', 'emp.xml');
    end;
    And the Error i got is :
    declare
    ERROR at line 1:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 424
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 46
    ORA-06512: at line 12

  • Using a data file in jsp to generate xml file

    hi
    can anybody help me to
    how to use a data file generated in unix in jsp to generate xml file.
    by using beans i am able to generate the xml.
    thanks in advance.

    You haven't provided adequate relevant information. If you need help provide proper relevant details.

  • Changing the directory Structure of Jsp and web.xml files

    Hi,
    I am using the JDeveloper 11g preview. Can any one tell me how to change the Jsp and web.xml files ( not in WEB-INF directory of the application) to another directory.
    Thanks in Advance
    Gopal

    Hi Frank,
    Is it possible for me to change the folder structure which JDeveloper is providing for web project?
    By default JDeveloper is giving the following folder structure.
    In the project's root folder there is a public_html and src folder along with .jpr file.
    In public_html folder thre is an WEB-INF folder and a jsp file
    In WEB-INF folder there is an classes folder along with web.xml file.
    I need to have the following folder structure :
    The WEB-INF folder should be in root folder of project not in public_html folder
    src folder must be in WEB-INF folder.
    Thanks in Advance
    Anil Golla

  • Import/export data from ms sql 7 to xml file in a particular xpdl format

    I'm trying to write java program to import/export data from ms sql 7 to xml file in a particular xpdl format. Can anyone suggest how to do it?

    take a glance at what these guys do: http://www.openbusinessengine.org/docs/guide.html

  • SSO problem when redirecting from a JSP page to an external application

    Hi,
    I try to make a redirect from a JSP page (that is under a SSO protected application on iAS) to another page from another application, on an external iAS server, also protected by (a different) SSO. After the redirection is done, the login window appears, I enter the login name and the password and after that I obtain the followin error:
    "Oracle SSO Failure - Unable to process request
    Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
    Please notify your administrator."
    In the logs og the server I found the following:
    [OSSO] W05: Requested URL is not specified in terms of fully-qualified host name or invalid SSO partner configuration. Host from request
    mycompany.com:7777, registered host 144.147.147.200:7778.
    (the ip address being the address of the mycompany.com host).
    Any clue about this? Thanks a lot in advance!
    Regards,
    Marinel

    Hi Carlo,
    Thanks for your answer.
    The JSP original page is not added as a partner application to the second SSO server.
    The idea was that the user should insert first the login name/passwd for the first server, after being logged in, then redirected to the second application (on a different server), insert the login name/password for the second application and then load the 2nd application page. It seems that is not working after inserting the password for the 2nd application.
    Coming to a more general question that could help me to avoid this complicated approach: is it possible to have two different applications deployed on two different iAS servers and the two applications to use the same SSO (let's say the one from the first iAS server)? I have to mention that the process scenario is the following: the user load a page from the first application (protected by SSO), then, after successfull login and some processing in the first app, he will be automatically redirected by the first app to the second application, on the second server. I want to have also the second application, on the 2nd server, protected by SSO (ideally would be the same SSO as the first one!). Ideally the scenario would be: if it is redirected from the first app and the user is already authenticated, the automatic redirection should be done transparently for the user (without enetring the password again). If the user goes directly from the browser to a page of the second app, the SSO login window should be displayed and the user should provide his password.
    Is such a scenario possible on two apps deployed on two different servers?!
    Thanks a lot again!
    Regards,
    Marinel

  • Using jsp creating the xml file on the browser

    Hi All,
    My problem is i have jsp page by which i am getting the data from data base, by using the database table i want to create the xml file
    can anybody help in this issue

    Oh, "the thing". Let me see if I can find that code for you ...

  • Selecting the first 4000 characters from a tag in an xml file

    Oracle Enterprise Edition 11.1.0.7 64 bit (Jan 2012 CPU applied)
    Windows 2003 64 bit
    We have an XML file with the following sample format.
    <?xml version="1.0"?>
    <HR>
    <EMP>
    <FNAME>JOHN</FNAME>
    <LNAME>DOE</LNAME>
    <COMMENT>Comment with less than 4000 characters</COMMENT>
    </EMP>
    <EMP>
    <FNAME>JANE</FNAME>
    <LNAME>DOE</LNAME>
    <COMMENT>Comment with more than 4000 characters</COMMENT>
    </EMP>
    </HR>
    The query below
    (full disclosure: which I took from odie_63's response in Creating External Table using Xml Dataset - how to include null values? and added the CURSOR_SHARING_EXACT hint on the top)
    works when the contents of the <Comment> tag are smaller than 4000 characters. If it is more than 4000 I get
    ORA-01706: user function result value was too large
    SELECT /*+ CURSOR_SHARING_EXACT */
    FROM XMLTable(
    '/HR/EMP'
    passing xmltype( bfilename('DATA_PUMP_DIR','emp.xml'), nls_charset_id('CHAR_CS') )
    columns
    first_name varchar2(30) path 'FNAME',
    last_name varchar2(30) path 'LNAME',
    comments varchar2(4000) path 'COMMENT'
    I found another query where someone was doing a substring (I think to get only the first 4000 characters from the tag) here.
    http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14638197 (See OP's post)
    TERMINATION_DATE VARCHAR(32) path 'TerminateDate/substring(text(), 1, 32)',
    So I updated my query to be
    SELECT /*+ CURSOR_SHARING_EXACT */
    FROM XMLTable(
    '/HR/EMP'
    passing xmltype( bfilename('DATA_PUMP_DIR','emp.xml'), nls_charset_id('CHAR_CS') )
    columns
    first_name varchar2(30) path 'FNAME',
    last_name varchar2(30) path 'LNAME',
    comments varchar2(4000) path 'COMMENT/substring(text(),1,4000)'
    The query runs without an error when the <comment> tag has 4000 or less characters but still errors out with it is more than 4000.
    I found an alternative method to do the SUBSTRING here in Herald ten Dam's reponse in Re: A view over XML that is not 1:1
    code varchar2(30) path 'substring(code,1,3)',
    so I tried this:
    SELECT /*+ CURSOR_SHARING_EXACT */
    FROM XMLTable(
    '/HR/EMP'
    passing xmltype( bfilename('DATA_PUMP_DIR','emp.xml'), nls_charset_id('CHAR_CS') )
    columns
    first_name varchar2(30) path 'FNAME',
    last_name varchar2(30) path 'LNAME',
    comments varchar2(4000) path 'substring(COMMENT,1,4000)'
    but that doesn't work either.
    How can I extract the first 4000 characters of the <COMMENT> tag so that the query doesn't fail.
    We are not using any other XMLDB features at this time. This is the first we've started looking into using Oracle built in XML features, so we might not have setup something that other's might know to specifically setup to start using the XML features in Oracle 11.1
    Thanks in advance,
    Wally

    walls99 wrote:
    This is regardless of the COMMENTS tag being 4000 characters or more and the same with the ideas from Odie.
    WallyNo idea if it is an issue with your version. I don't have your version to test but following works for me. Does this simple test work?
    SQL> select * from v$version ;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL> set define off
    SQL> select dbms_xmlgen.convert(xmlserialize(content xmltype('<brand>Ben &amp; Jerry</brand>') as clob), 1) from dual ;
    DBMS_XMLGEN.CONVERT(XMLSERIALIZE(CONTENTXMLTYPE('<BRAND>BEN&AMP;JERRY</BRAND>')A
    <brand>Ben & Jerry</brand>

  • Inserting a value from page field into an xml file

    Hi there,
    I have added a field 'Comments' on a create vacancy page.
    There are other fields on that page and the values from those fields are getting stored in an xml file.
    This xml file is getting stored in TRANSACTION_DOCUMENT column of table HR_API_TRANSACTIONS.
    Is it possible to add the value from the field (that I've added on the page) into the same xml file?
    If yes, please tell me how
    and if no, tell me what should I do to store that value.
    Regards,
    Gaurav.

    Hi Gaurav,
    You need to check in seeded files for the logic of generation of XML file and setting it in DB column. May be in PLSQL API this code would exist.
    Once you get that logic you can append your column value in XML tag (need to create new tag) if you are allowed to modify seeded API. Otherwise use free additional attributes of the table.
    Hope I am clear.
    Regards,
    Mukesh Uchaniya

  • Is it possible to create a table from the input of an XML file

    Hi,
    Must the table exist when I try to parse data from an XML file, or can I tell the parser to create the table if it doesn't exists.
    thanks
    Rune Haavik

    Rune,
    XML Parsing on Java side does not require any table(s) to be present.
    If you are talking about PLSQL parsers, then I guess you can catch the exception in your PLSQL block and then create a table. This falls in the SQL realm.
    I hope this answers your question.

  • Exporting data from database tables to a XML file

    Hi,
    We want to export data from Oracle database tables to an XML
    file. What tool can we use for this purpose, and how do we go
    about it ?
    Can we extract data only from an Oracle8 database, or can we
    extract data from Oracle7.3 databases too ?
    Any help in this regard would be appreciated.
    Thanks
    Dipanjan
    null

    Dipanjan (guest) wrote:
    : Hi,
    : We want to export data from Oracle database tables to an XML
    : file. What tool can we use for this purpose, and how do we go
    : about it ?
    : Can we extract data only from an Oracle8 database, or can we
    : extract data from Oracle7.3 databases too ?
    : Any help in this regard would be appreciated.
    : Thanks
    : Dipanjan
    Start by downloading the XML SQL Utility and make sure you have
    the approriate JDBC 1.1 drivers installed for your database.
    There are samples which will get you going included in the
    archive.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Use jsp to read xml file

    Gents,
    I'm a XML & JSP newbie and try to do the following: I have a xml file which can be opened with a browser so that I can see data (let's say my cd collection). Further I have a xls file which makes the display a little nicer, with colors and so. Now, I want to have a jsp page read this xml file and I'm not very succesfull, while I spent hours and hours on Google, but nothing.
    What I did so far, was:
    - download & install Tomcat 5.5
    - make a dir under webapps\mycdcollection
    - copy my xml files to webapps\mycdcollection
    - make a dir webapps\mycdcollection\WEB-INF
    - make a dir webapps\mycdcollection\WEB-INF\lib
    - copy standard.jar & jstl.jar to BOTH webapps\mycdcollection\WEB-INF\lib as webapps\ROOT\WEB-INF\lib
    Here are my questions:
    - How should my web.xml in webapps\mycdcollection\WEB-INF look like?
    - Should I precompile my jsp? If so, should there be a classes directory somehwere? How should I make my app know that there is a classes directory?
    I'm sure I will have lots more of questions, but if you can get me on the way I'd be very thankful.

    hi,
    u can interact with xml while in jsp. we have jstl (xml) tags to interact with the xml files.
    use the jstl and copy the jar files neede for the jstl in to ur web app folder. u need to copy jstl.jar, standard.jar, jaxen.jar, and optionally (saxpath.jar and xalan.jar) based on the versions of the jstl ur using.
    mail me at [email protected], if u have any problems.
    Here, are some urls' go through with this,
    http://www.roseindia.net/jstl/introduction.shtml
    http://www-128.ibm.com/developerworks/java/library/j-jstl0318/
    http://jcp.org/aboutJava/communityprocess/final/jsr052/index2.html
    regards,
    pavan

  • Reference a DSL from CDATA section in an Xml file

    I use a DSL along with some XML files in an Eclipse project. I would like to reference some of the DSL entities from within a CDATA section in the XML files and provide content assist for doing so.
    Would I need to define a DSL for the XML and then implement some DSL cross referencing ?
    Would I lose the default XML features of Eclipse if I do so ?
    Is there a way to overload the XML support built into Eclipse for implementing this ?

    I don't know about the extension capabilities of the XML editor. You would need to investigate how this editor can be extended first. This might be a question for Eclipse Web Tools Platform, if you use that XML editor (there are several XML editor plugins available).

  • Is there anyway to create a xml file from a list so that xml file is available like an RSS.xml

    Hello
    My objective is to have a xml file created from a list for anonymous access.  The SharePoint RSS feed is a .aspx file not xml, as shown below: 
    _layouts/listfeed.aspx?List=21c2cdaa%2D52f3%2D4057%2Db674%2D45e63ba77e31&View=535eb328%2Db5fb%2D45c5%2D8fe8%2Da130e92afc41
    Also, is there a way to do this so that the xml content has current data like the list.
    Thank you for any insight and direction.

    Hi,
    According to your post, my understanding is that you wanted to create a xml file from a SharePoint list.
    To generate a XML file, we can use the SharePoint Object Model or PowerShell to achieve it.
    Generate a hierarchical XML file from SharePoint list using Client Object Model.
    http://maxderungs.wordpress.com/2012/05/12/generate-a-hierarchical-xml-file-from-sharepoint-list/
    Get SharePoint list items and export them to XML using PowerShell
    http://www.robertkuzma.com/2012/09/get-sharepoint-list-items-and-export-them-to-xml-using-powershell/
    More reference:
    http://www.robertkuzma.com/2010/08/how-to-create-a-custom-xml-output-using-sharepoint-services-3-0/
    http://traceynolte.com/blog/convert-sharepoint-list-to-xml/
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Generate XSD from an not well formed xml File

    Hi,
    I have following problem:
    XML File:
    <readme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://localhost:8888/home/XDB/xsd/readme_neu.xsd">
         <title lang="de-DE">Preisliste Antriebselektronik </title>
         <title lang="en-DE">Preisliste Antriebselektronik </title>
         <edition lang="de-DE">date</edition>
         <doctype lang="de-DE">Preisliste</doctype>
         <projectstartdate lang="de-DE">date</projectstartdate>
         <projectenddate lang="de-DE">date</projectenddate>
    <projectenddate lang="en-DE">date</projectenddate>
         <status lang="de-DE">Druckvorstufe</status>
         <doku-key>PA300000</doku-key>
         <orderno lang="de-DE">
         <actual>11500204</actual>
         <previous>11341408</previous>
         </orderno>
         <orderno lang="lv-LV">
              <actual>11500476</actual>
              <previous>11341653</previous>
         </orderno>
         <orderno lang="lt-LT">
              <actual>11500484</actual>
              <previous>11341661</previous>
         </orderno>
         <orderno lang="nl-BE">
              <actual>11500492</actual>
              <previous>11341688</previous>
         </orderno>
    </readme>
    The Tags title and projectenddate makes the problem. I'd like to make an Objekt TITEL_OBJECT and PROJECTEND_OBJECT to differ the tags, but my problem is:
    xdb_titel_type is NOT FINAL
    Name Null? Typ
    SYS_XDBPD$ XDB$RAW_LIST_T
    SPRACHE VARCHAR2(4000 CHAR)
    that I lose the content the tags.
    What can i do?? is there any possible solution or isn't it possible
    thx PHIL
    I have solved the problem
    Message was edited by:
    user534856

    Hi,
    I have following problem:
    XML File:
    <readme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://localhost:8888/home/XDB/xsd/readme_neu.xsd">
         <title lang="de-DE">Preisliste Antriebselektronik </title>
         <title lang="en-DE">Preisliste Antriebselektronik </title>
         <edition lang="de-DE">date</edition>
         <doctype lang="de-DE">Preisliste</doctype>
         <projectstartdate lang="de-DE">date</projectstartdate>
         <projectenddate lang="de-DE">date</projectenddate>
    <projectenddate lang="en-DE">date</projectenddate>
         <status lang="de-DE">Druckvorstufe</status>
         <doku-key>PA300000</doku-key>
         <orderno lang="de-DE">
         <actual>11500204</actual>
         <previous>11341408</previous>
         </orderno>
         <orderno lang="lv-LV">
              <actual>11500476</actual>
              <previous>11341653</previous>
         </orderno>
         <orderno lang="lt-LT">
              <actual>11500484</actual>
              <previous>11341661</previous>
         </orderno>
         <orderno lang="nl-BE">
              <actual>11500492</actual>
              <previous>11341688</previous>
         </orderno>
    </readme>
    The Tags title and projectenddate makes the problem. I'd like to make an Objekt TITEL_OBJECT and PROJECTEND_OBJECT to differ the tags, but my problem is:
    xdb_titel_type is NOT FINAL
    Name Null? Typ
    SYS_XDBPD$ XDB$RAW_LIST_T
    SPRACHE VARCHAR2(4000 CHAR)
    that I lose the content the tags.
    What can i do?? is there any possible solution or isn't it possible
    thx PHIL
    I have solved the problem
    Message was edited by:
    user534856

Maybe you are looking for

  • Using a SDO_FILTER in a JDBC GeoRaster Query

    Hi, I have the following query which works perfectly: http://192.168.33.52:8888/mapviewer/wms?REQUEST=GetMap &SERVICE=WMS &VERSION=1.1.1 &LAYERS= &mvthemes= <themes> <theme name="geor_theme"> <jdbc_georaster_query jdbc_srid="8307" datasource="WMS" ge

  • New Nvidia driver to resolve crash/quit issues in Premiere Elements 8.

    For Nvidia users, there is a driver update that will fix both of the following issues: Premiere Elements 8 does not restart after closing on Windows Frequent and inexplicable crashes with Premiere Elements 8 To resolve these issues, you should update

  • Program used to create object is Package

    when I attempt to copy and paste a shorctut to a file on a network drive into an MS-word 2007 File i get an error message that states 'the program used to create this object is Package.  That Program is not installed on yourt computer.  To Edit this

  • Selecting multiple tracks to assign compilation tag

    Hello, If I right click on a single track and select "get info" I can check the "part of compilation" check box. However, if I select multiple songs from a compilation album, the check box is no longer present under the info tab. Is this a bug with t

  • Bridge CS5 Collection is seeing deleted items

    I have some done some housekeeping of about 75 to 100 folders recently.  I now want to create some contact sheets from a collection using the images from these folders now that i have eliminated the duplicate images/multiple exposures that i don't ne