Forwarding to an xml file from jsp page

hi
i am subhash. i have problem in forwarding an xml file from jsp page.
i have a jsp page in which i have a button. upon click, its form method is triggered and the action is set to "serverpage.jsp". In that jsp page i have to move to an xml file. I would like u to send a sample code also for the same.
Thank You,
Subhash..

Refer to the Generating XML from JSP section.
http://java.sun.com/developer/technicalArticles/xml/WebAppDev2/

Similar Messages

  • How to call cystal report8 report file from jsp page

    hi guys
    present i am using cystal report8 already i am having ReportViewer.jar and ReportviewerBean.jar files
    using that please send me sample code how to call that report from jsp page..
    and how to pass the parameters from jsp page to crystalreport8 report file.
    it was very urgent task to me..so please send sample code on above topic..
    or send me crystalreport8 API
    thanks
    regards

    Hi,
    I also want to work on crystal report but i dont have the ReportViewerBean.jar and ReportViewer.jar. So, please tell from where will i get those jar files.
    Thanks in advanced.

  • Writing an XML file from JSP

    Hi
    for some this question will seem to be a stupid, but i am really confused how can i write an XML file from with in JSP code. should i have to use same FileOutPutStream.
    Actually i am trying to make reports using Jasper api. It demands for an XML file which will then b converted into PDF file. Can any one help me in it.

    Jasper converts a JSP into a servlet - and cannot be used to generate PDFs.
    Assuming this is for a web application I would
    1. Generate the XML
    2. Generate the PDF from the XML
    3. Send the PDF to the client from a servlet (i.e. forget the JSP).
    Step 2 is actually quite complicated - you could do this manually with the IText API (http://www.lowagie.com/iText/) or use an XSL approach with Apache FOP (http://xmlgraphics.apache.org/fop/)

  • Include xml file in jsp page

    hi,
    i just would like to include an xml file and his xsl file in a jsp page.
    i know we can do it in asp like that :
    <%
    //load the xml file
    var source = Server.CreateObjetc("Microsoft.XMLDOM");
    source.load(Server.MapPath("toto.xml"));
    //load the associated xsl file
    var style = Server.CreateObject("Microsoft.XMLDOM");
    style.load(Server.MapPath("toto.xsl"));
    //transform the source document
    var result = source.transformNode(style);
    Response.Write(result);
    %>
    i want exactly do the same in jsp
    does anyone know how to do?

    where is the big deal? there are many posts answering this in the forum.
    here is a possibility:
    <%@page contentType="text/html;charset=utf-8"%>
    <%@page import="javax.xml.transform.*,javax.xml.transform.stream.*" %><%
    Templates myTemplates = TransformerFactory.newInstance().newTemplates(new StreamSource(new File("whatever.xsl")));
    Transformer transformer = myTemplates.newTransformer();
    StringWriter sw = new StringWriter();
    transformer.transform(new StreamSource(new File("whatever.xsl")), new StreamResult(sw));
    out.print(sw.toString());
    %>

  • Read xml file from jsp/servlet

    Hi all,
    I am a new comer to jsp and really appreciate if someone can help me on this:
    I will like to use a xml file to control access to my web app instead of using a database. Let say user.xml that will contains user name and password. Questions:
    1. where should I put this file? Under WEB-INF?
    2. In my jsp or servlet, how do i read the xml file, i mean how to i refer to the file (depend on question 1 as where the file should be placed)?
    Thank you very much.
    Sim

    Hi jlsim,
    you can place the xml file where you want, but remember that placing it under /WEB-INF is the most security way.
    I had a similar problem and I placed the xml file under /WEB-INF directory.
    To refer to it I did something like this:
    String realPath=getServletContext().getRealPath("WEB-INF/xml/workspaces.xml");//obtain the real path
    File f=new File(realPath);//obtain an instance of your file usable
    //to create an InputStream

  • Uploading a file from jsp page on weblogic portal 9.2 into VCR content node

    I am working on Content Management in Weblogic Portal 9.2 using the com.bea.content API. I have succedded to the extent that I have created "Node" both Hierarchy and Content Node in the Virtual Content Repository using the CM API from a JSP.
    Now I have to upload a file from this JSP into VCR Content Node. I am facing some problems. I am not able to figure out which class to use for this purpose from CM API. Please help in this regard.

    Hi,
    You need to ensure you're using an ObjectClass with a PropertyDefiition of type Property.BINARY. Then, construct a BinaryValue with your InputStream. Use that to construct the Value and Property for the Node you're creating or updating.
    -Ryan

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • Writing XML file from a jsp page

    how can i write a xml file from my jsp and store the values and after sometime, for example when the user clicks on the submit button, i check the values from xml file and compare those values from the data base.
    it means both writing and reading xml file from a jsp page...
    urgent help needed......thanks

    You need some API like XSL or JDOM to read data from/to XML file
    you can get a best tutorial from
    http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom.html
    and
    http://www.javaworld.com/javaworld/jw-07-2000/jw-0728-jdom2.html
    after reading both articals you will be able to do both the tasks

  • Read XML file from different server on JSP

    Dear All,
    I am a newbie to JSP with XML, now i want to read the "test.xml" from JSP.
    I read successfully this "test.xml" file from my system and I got output, but I need to read the xml file from
    different server like "http://www.domain.com/test.xml". I couldn't read such a type of file from different server.
    Is it possible to read a xml file from different server?
    If anybody have idea please let me know.
    Thanks in Advance,
    Prasath.
    <%@ page import="java.sql.*,java.io.*,java.util.*,javax.xml.parsers.*,org.w3c.dom.*,org.xml.sax.*" %>
    <%
    try {
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        Document doc = docBuilder.parse (new File("http://www.domain.com/test.xml"));
        // normalize text representation
        doc.getDocumentElement ().normalize ();
        out.println ("Root element of the doc is " +
             doc.getDocumentElement().getNodeName()+"<br>");
        NodeList listOfPersons = doc.getElementsByTagName("person");
        int totalPersons = listOfPersons.getLength();
        out.println("Total no of people : " + totalPersons+"<br>");
        for(int s=0; s<listOfPersons.getLength() ; s++){
            Node firstPersonNode = listOfPersons.item(s);
            if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){
                Element firstPersonElement = (Element)firstPersonNode;
                NodeList firstNameList = firstPersonElement.getElementsByTagName("first");
                Element firstNameElement = (Element)firstNameList.item(0);
                NodeList textFNList = firstNameElement.getChildNodes();
                out.println("First Name : " +
                       ((Node)textFNList.item(0)).getNodeValue().trim()+"<br>");
                NodeList lastNameList = firstPersonElement.getElementsByTagName("last");
                Element lastNameElement = (Element)lastNameList.item(0);
                NodeList textLNList = lastNameElement.getChildNodes();
                out.println("Last Name : " +
                       ((Node)textLNList.item(0)).getNodeValue().trim()+"<br>");
                NodeList ageList = firstPersonElement.getElementsByTagName("age");
                Element ageElement = (Element)ageList.item(0);
                NodeList textAgeList = ageElement.getChildNodes();
                out.println("Age : " +
                       ((Node)textAgeList.item(0)).getNodeValue().trim()+"<br>");
            }//end of if clause
        }//end of for loop with s var
    }catch (SAXParseException err) {
    out.println ("** Parsing error" + ", line "
         + err.getLineNumber () + ", uri " + err.getSystemId ());
    out.println(" " + err.getMessage ());
    }catch (SAXException e) {
    Exception x = e.getException ();
    ((x == null) ? e : x).printStackTrace ();
    }catch (Throwable t) {
    t.printStackTrace ();
    %>

    You might try:
    Document doc = docBuilder.parse ("http://www.domain.com/test.xml");Alternatively use the java.net package to obtain an Input Stream to the xml document
    InputStream in = methodThatYouWriteYourselfCalledgetInputStreamForURI("http://www.domain.com/test.xml");
    Document doc = docBuilder.parse (in);cheers,
    evnafets

  • Out put file is not genrated when calling xml reports from OAF page

    Dear all
    i am calling xml reports from OAF page
    the out put file is not generated
    i am writing this code
    public int tradingrequest(String quoid, String costoder,int orgid)
    try
    OADBTransaction tx = (OADBTransaction)getOADBTransaction();
    java.sql.Connection pConncection = tx.getJdbcConnection();
    ConcurrentRequest cr = new ConcurrentRequest(pConncection);
    String applnName =
    "XXCRM"; //Application that contains the concurrent program
    String cpName = "XXCRM_COSTSHEET"; //Concurrent program short name
    String cpDesc =
    "Trading Costsheet Report XXCRM"; // concurrent Program description
    Number orgid1=new Number(orgid);
    // Pass the Arguments using vector
    Vector cpArgs = new Vector();
    cpArgs.addElement(quoid);
    cpArgs.addElement(costoder);
    cpArgs.addElement(orgid1.toString());
    // Calling the Concurrent Program
    int requestId =
    cr.submitRequest(applnName, cpName, cpDesc, null, false, cpArgs);
    tx.commit();
    System.out.println("Request ID is " + requestId);
    return requestId;
    } catch (RequestSubmissionException e)
    OAException oe = new OAException(e.getMessage());
    oe.setApplicationModule(this);
    throw oe;
    in controller i am writing this code
    OAMessageStyledTextBean y =
    (OAMessageStyledTextBean)webBean.findChildRecursive("quotationid");
    OAFormValueBean z =
    (OAFormValueBean)webBean.findChildRecursive("costorder");
    String quoid = y.getValue(pageContext).toString();
    String costorder = z.getValue(pageContext).toString();
    System.out.println("The quotation id and costing order are....." + quoid +
    " " + costorder);
    /*if click on run report button to run the report*/
    if ("Viewreport".equals(pageContext.getParameter(EVENT_PARAM)))
    if (tsflag.equals("Y"))
    int requestid = am.servicerequest(quoid, costorder, orgid);
    String url =
    "OA.jsp?akRegionCode=FNDCPREQUESTVIEWPAGE&akRegionApplicationId=0&retainAM=Y&addBreadCrumb=Y&REQUESTID=" +
    requestid;
    pageContext.setForwardURL(url, null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT, null,
    null, true,
    OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
    OAWebBeanConstants.IGNORE_MESSAGES);
    when i call the report from oaf page the request id is coming
    when i click on view output i am getting this message
    Error
    The concurrent request 7335031 did not create an output file.
    WHEN I GOTO FIND REQUESTS PAGE QUERY THIS REQUEST ID I AM GETTING THE OUTPUT IN XM FILE
    Regards
    Sreekanth

    java.io.FileNotFoundException: \..\..\..\xdoAqdFFZfuuJ051010_0628487460.fo (The system cannot find the path specified)
    MY CO code
    if("GenerateReport".equals(event))
    // Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.
    DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
    HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
    try {
    // Hashtable hashtable = new Hashtable(1);
    // hashtable.put("TruckBookingRefNum",trucknum);
    // System.out.println("test"+trucknum);
    ServletOutputStream os = response.getOutputStream();
    // Set the Output Report File Name and Content Type
    String contentDisposition = "attachment;filename=LF Cargo Summary Report.htm";
    response.setHeader("Content-Disposition",contentDisposition);
    response.setContentType("application/HTML");
    // Get the Data XML File as the XMLNode
    XMLNode xmlNode = (XMLNode) am.invokeMethod("getTestDataXML");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    xmlNode.print(outputStream);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
    System.out.println(" ByteArrayInputStream.ByteArrayOutputStream"+pdfFile+inputStream);
    //Generate the PDF Report.
    TemplateHelper.processTemplate(
    ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
    "LFCUST",
    "XXLFCARSUM_TARGET",
    "English",//((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
    "US",//((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
    inputStream,
    TemplateHelper.OUTPUT_TYPE_HTML,
    null,
    pdfFile);
    // hashtable);
    System.out.println(" TemplateHelper");
    // Write the PDF Report to the HttpServletResponse object and flush.
    byte[] b = pdfFile.toByteArray();
    System.out.println(" byte"+b);
    response.setContentLength(b.length);
    os.write(b, 0, b.length);
    os.flush();
    os.close();
    pdfFile.flush();
    pdfFile.close();
    catch(Exception e)
    System.out.println(" inside catch");
    response.setContentType("text/html");
    throw new OAException(e.getMessage(), OAException.ERROR);
    pageContext.setDocumentRendered(true);
    Edited by: user9367919 on May 13, 2010 10:31 AM

  • How to retrieve xml file from BLOB and display on browser with css/xslt

    Hi All,
    I am new to xml. I am storing my xml file into BLOB in database. Now in my jsp page I want to retrieve this xml file from BLOB and display in HTML/CSS/XSLT form...
    Pl. guide me.. any docs..?? Logic...??
    Thanks in Advance.
    Sandeep Oza

    Hello Sandeep!
    I'm not familiar with jsp but logic should be as follows:
    -in jsp page instantiate XML parser
    -load specified BLOB into parser
    Now you may traverse the XML tree or you might load XSL file and use transform method to transform XML according to XSL file.
    I have an example where I'm selecting XML straight from relational database and then transform it using XSL into appropriate HTML output, but it's written in PSP.
    You can try http://www.w3schools.com/default.asp for basics on XML, CSS, XSL. It's easy to follow with good examples.
    Regards!
    miki

  • Send message from JSP page to Java message driven bean

    Hi all
    I'm using Jdev903.
    I need to send a message from JSP page (Web Application) to Java Message Driven Bean.
    * I created Message Driven Bean that named: MyMessageDrivenEJBBean
    * I have configed jms.xml:
    <topic-connection-factory name="ChatTopicConnectionFactory" location="jms/theTopicConnectionFactory"/>
    <topic name="ChatTopic" location="jms/theTopic"/>
    * In JSP page, my code is:
    final Context ctx = new InitialContext();
    // 1: Lookup ConnectionFactory via JNDI
    TopicConnectionFactory factory =(TopicConnectionFactory)ctx.lookup("jms/theTopicConnectionFactory");
    But trouble occurs is:
    javax.naming.NameNotFoundException: jms/theTopicConnectionFactory not found
    please help me!
    thank a lot.

    Welcome to the Sun forums.
    1. Please post your code using code tags, this formats it so that it is easier for people to read and understand it. Click on 'CODE' above the text area when posting.
    2. As far as possible, please post an SSCCE
    What have learnt about JSPs and servlets till now? Because reading the values submitted in a form is pretty much the base of all operations. I suggest you Google for [servlet tutorials|http://www.google.com/search?q=servlet+tutorial] and [JSP tutorials|http://www.google.com/search?q=jsp+tutorial] and go through them thoroughly. After you understand what is to be done and what options are available to you, if you still face problems, please feel free to post your queries here. But this isn't exactly a site for tutorials, especially since there are so many good ones already out there, that explain all this stuff in detail. There's no point in re-inventing the wheel.
    Hints: [ServletRequest#getParameter()|http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)] and [RequestDispatcher#forward|http://java.sun.com/javaee/5/docs/api/javax/servlet/RequestDispatcher.html]

  • Best Practices:: How to generate XML file from a ResultSet

    Hi all,
    Could someone please suggest the best practices of how to generate an XML file from a resultset? I am developing a web application in Java with Oracle database and one of my tasks is to generate an XML file when the user, for example, click a "download as XML" button on the JSP. The application is basically like an Order with line items. I am using Struts and my first thought has been to have an action class which will extend struts's DownloadAction and through StAX's Iterator API to create an XML file. I intend to have a POJO which will have properties of all columns of my order and line items tables so that for each order I get all line items and:
    1. Write order details then
    2. Through an iterator write line items of that order to an XML file.
    I will greatly appreciate for comments or suggestions on the best way to do this through any pointers on the Web.
    alex

    Use a OracleWebRowSet in which an XML representation of the result set may be obtained.
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/oracle10g/webrowset/Readme.html
    http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/jcrowset.htm

  • Product Instance Registration Error Message: "System Failure: Error while retrieving xml file from database"

    Hi Planning installation Gurus,
    Did u get any luck to resolve this problem as i am also facing same problem "Error creating instance" during install of Planning 9.3.1. i tried 30-50 times reconfiguration every time same problem..
    OS: Vista Premium
    SQL Server 2005
    Essbase:9.3.1
    Error Message: "System Failure: Error while retrieving xml file from database"
    Details of error:::::::::::::::::::::::::
    at com.hyperion.planning.event.HspSysExtChangeHandler.run(Unknown Source
    Can not get JDBC connection for SYS external changed actions.
    Can not get JDBC connection.
    java.lang.NullPointerException
    at com.hyperion.planning.sql.HspSQLImpl.getConnection(Unknown Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.actionPoller(Unkno
    wn Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.run(Unknown Source
    Can not get JDBC connection for SYS external changed actions.
    Can not get JDBC connection.
    java.lang.NullPointerException
    at com.hyperion.planning.sql.HspSQLImpl.getConnection(Unknown Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.actionPoller(Unkno
    wn Source)
    at com.hyperion.planning.event.HspSysExtChangeHandler.run(Unknown Source
    Can not get JDBC connection for SYS external changed actions.
    Can not get JDBC connection.
    Pls provide Solution

    Hi John,
    though i am trying with SQl server authentication with different user but still status is same of planningSystemDB.properties
    SYSTEM_DB_DRIVER=hyperion.jdbc.sqlserver.SQLServerDriver
    SYSTEM_DB_URL=jdbc:hyperion:sqlserver://neeraj-PC:1433
    SYSTEM_DB_USER=windowsAuthentication
    SYSTEM_DB_PASSWORD=CAFBAEFNBGEAABHEDOADFKADACBGBIFHBLCDFBAFFH
    SYSTEM_DB_CATALOG=plandb
    SYSTEM_DB_TYPE=SQL
    INSTANCE=
    my steps:
    Using SQL Server Management Studio
    Changed Widows authentication to SQL server authentication mode
    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
    To restart SQL Server from SQL Server Management Studio
    To enable the sa login by using Management Studio
    In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.
    On the General page, you might have to create and confirm a password for the sa login.
    On the Status page, in the Login section, click Enabled, and then click OK.
    In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.
    On the General page, you might have to create and confirm a password for the sa login.
    On the Status page, in the Login section, click Enabled, and then click OK.}}}
    anything else should i change.................

  • Creating an xml file from recordset

    Hi...
    XML newbie here - so.
    Is it possible to create and xml file from a recordset?
    I need to create a datafeed of our e-commerce products.
    Also, some of the db data contains HTML Code (product
    description field),
    how will this effect the xml file?
    Another problem is that my xml file needs to contain url's
    for the products
    and product images. My ASP pages contain these URL in hard
    code and then
    pull the actual file names from the db
    Hope that makes some sense
    Thanks for any help
    Andy

    Hi David
    Thanks for your help.
    I think it will have to be option 1 as i am using Access DB.
    I don't know how to go about it but will serach good old
    Google.
    Here is my recordset below, that pulls the required data from
    Access.
    The product and product image URL's need to be in the xml
    file but only the
    product image name and product id are in the database, e.g
    image name
    (imagename.jpg) productid (21)
    The actual URL's are hardcoded in my ASP pages, e.g <img
    src="products/medium/<%=(RSDetails.Fields.Item("Image").Value)%>"
    Not sure if this makes things any clearer :-|
    Thanks Again
    Andy
    <%
    Dim RSdatafeed
    Dim RSdatafeed_numRows
    Set RSdatafeed = Server.CreateObject("ADODB.Recordset")
    RSdatafeed.ActiveConnection = MM_shoppingcart_STRING
    RSdatafeed.Source = "SELECT Products.Product,
    Products.Description,
    Products.Image, Products.image2, Products.ListPrice,
    Products.Price,
    Products.xml_feed, Manufacturers.Manufacturer,
    Shipping.ShippingCost FROM
    Shipping, Products INNER JOIN Manufacturers ON
    Products.ManufacturerID =
    Manufacturers.ManufacturerID WHERE
    (((Products.xml_feed)=No));"
    RSdatafeed.CursorType = 0
    RSdatafeed.CursorLocation = 2
    RSdatafeed.LockType = 1
    RSdatafeed.Open()
    RSdatafeed_numRows = 0
    %>
    "DEPearson" <[email protected]> wrote in
    message
    news:[email protected]...
    > Andy,
    >
    > There are two ways you can create a xml file from a
    recordset
    >
    > 1. Is to code it using Server.CreateObject(XMLDOM)
    > 2. If you are using SQL server 2005, just request the RS
    returns as XML
    > data. using FOR XML AUTO after the where cause ( the
    best way with 2005
    > and
    > higher sql server)
    >
    > The db data containing HTML code should not effect your
    xml file, unless
    > it
    > is bad markup. You could wrap the data with
    <![CDATA[the data or html
    > markup, or javascript]]>
    >
    > If the url is a recordset field, then it will return
    with the xml data.
    > If
    > not you can create a storage procedure that will build
    your URL from the
    > data
    > in the database.
    >
    > It is best to use storage procedure (SP )for security
    reason when pulling
    > data
    > from a MS Sql server, make all calls to the database in
    a SP. Also be sure
    > to
    > validate the values in the querystrings before accepting
    them, check for
    > hack
    > code.
    >
    > David
    >

Maybe you are looking for