Problem in getting attribute from request.

HI
I have a JSR 168 portlet which was earlier running in tomcat 6 and liferay...i'm now migrating that in webcenter portal framework 11g.
after migration when i run it ... i have set some attribute in actionRequest class of processAction method in my portlet and then i 'm getting it in jsp from request(explicit varriable) varriable....
this was working earlier in liferay/tomcat but somehow it's not working here ... i didn't change any code here... apart from some lspecific ib/class from liferay to oracle.
please suggest
thanks

I think you are mixing some things...
First of all, if you are creating basic JSP portlets, you don't need to use the ADFPortletBridge. This is only needed when you develop JSF portlets and are using the ADF technology.
Second of all, you are switching from JSR 168 to 286. The standard has some changes but i don't really know if these changes affect the lifecycle of the portlets in a way that the setAttribute will be broken...
There are a lot of changes in the parameters so IPC is made easy with JSR 286.
Maybe you cna elaborte some more about the specific case and we can provide a valid workaround?

Similar Messages

  • Xpath: get attributes from first child node

    Hi,
    I have some problems by getting the attributes from the first child node, if i try to get child elements everything works fine, but whenever i need the elementvalue from a node with attributes i doesn't return anything.
    The xpath expression works fine if i want to get the element value from all childs, but not when i just want from one of them.
    This one works,
    XPathFactory factory1 = XPathFactory.newInstance();
        XPath xpath = factory1.newXPath();
        xpath.setNamespaceContext(new PersonalNamespaceContext());
        XPathExpression expr
         = xpath.compile("//default:DeviceExchange[1]/default:Status/text()");
       // gets the value of the node picked out
        Object result = expr.evaluate(doc, XPathConstants.NODESET);
        NodeList nodes = (NodeList) result;
        for (int i = 0; i < nodes.getLength(); i++) {
          names[i] = nodes.item(i).getNodeValue();
          String a = names;
    // checks if status is exchanged, if it is sets status to 1
    if (a.length() == 9){
    names[i] = "1"; }
    else{  names[i] = "0";}
    System.out.println(names[i]);This doesn'tXPathFactory factory2 = XPathFactory.newInstance();
    XPath xpath2 = factory2.newXPath();
    xpath2.setNamespaceContext(new PersonalNamespaceContext());
    XPathExpression expr2 = xpath2.compile("//default:DeviceExchange[1]/default:Field[@names='MLPKTID']/text()");
    Object result2 = expr2.evaluate(doc, XPathConstants.NODESET);
    NodeList nodes2 = (NodeList) result2;
    for (int i = 0; i < nodes2.getLength(); i++) {
    names2[i] = nodes2.item(i).getNodeValue();
    System.out.println(names2[i]);}Does anyone have any ideas? I will apreciate all help!
    Edited by: fusen on Oct 25, 2007 1:12 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Sorry, solved myself. Just � typo that that i couldn't detect.

  • Problem to get Connection from JBoss AS

    PLEASE HELP ME....
    I GOT ERROR WHILE I TRYED TO GET A CONNECTION FROM JBOSS APP. SERVER.
    THE CODE IS
    package com.beo.atlas.common;
    public final class ServiceLocator     {
         private static final String JBOSS_INITIAL_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
         private static final String JBOSS_PROVIDER_URL = "localhost:8080";
         private static final String JBOSS_URL_PKG_PREFIXES = "org.jboss.naming:org.jnp.interfaces";
         public static final String ATLAS_DATASOURCE = "java://myatlasdbpool";
         private static java.util.Hashtable dataSourceCache = null;
         private static ServiceLocator locator = null;
         static     {
              System.out.println("Locator Initializing");
              dataSourceCache = new java.util.Hashtable();
              locator = new ServiceLocator();
         private ServiceLocator()     {     }
         public static ServiceLocator newInstance()     {
              System.out.println("Returning the Locator Object");
              return locator;
         public java.sql.Connection getDBConnection() throws java.sql.SQLException,javax.naming.NamingException     {
              System.out.println("Getting Data base Connection....");
              if(dataSourceCache.containsKey(ATLAS_DATASOURCE))     {
                   System.out.println("Trying to get Connection from CACHE...");
                   System.out.println("Returning Connection Object from cache.");
                   return (java.sql.Connection)dataSourceCache.get(ATLAS_DATASOURCE);
              System.out.println("FAILED to get Connection from CACHE");
              System.out.println("Trying to create new Connection...");
              java.util.Properties props = new java.util.Properties();
              props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,JBOSS_INITIAL_CONTEXT_FACTORY);
              props.put(javax.naming.Context.PROVIDER_URL,JBOSS_PROVIDER_URL);
              props.put(javax.naming.Context.URL_PKG_PREFIXES, JBOSS_URL_PKG_PREFIXES );
              javax.naming.InitialContext context = new javax.naming.InitialContext(props);
              Object o = context.lookup(ATLAS_DATASOURCE);
              System.out.println("Object Created...");
              javax.sql.DataSource dataSource = null;
              try     {
              dataSource = (javax.sql.DataSource)javax.rmi.PortableRemoteObject.narrow(o,javax.sql.DataSource.class);
              }catch(Exception e)     {     
              java.sql.Connection con = dataSource.getConnection();
              dataSourceCache.put(ATLAS_DATASOURCE,con);
              System.out.println("Returning new Connection Object.");
              return con;          
    ERROR
    Locator Initializing
    Returning the Locator Object
    Getting Data base Connection....
    FAILED to get Connection from CACHE
    Trying to create new Connection...
    Object Created...
    java.lang.ClassCastException
    at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown S
    ource)
    at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    at com.beo.atlas.common.ServiceLocator.getDBConnection(ServiceLocator.ja
    va:56)
    at AtlasClient.printData(AtlasClient.java:16)
    at AtlasClient.main(AtlasClient.java:8)
    Caused by: java.lang.ClassCastException: org.jnp.interfaces.NamingContext
    ... 5 more

    I've got the same problem. Working with JBoss 4.0.3 and Tomcat 5.5. The lookup goes fine and returns an object of type remote home, however when I perform the narrow() I get ClassCastException. I'm sure the client and the server have got the same file version as I built from the same source.
    [error]
    Caused by: java.lang.ClassCastException
         at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
    [error]

  • Getting Attributes from an org unit

    Hi
    How can I get attributes and their values given an organization unit?? ie org id?
    Is there any function module or any tables which contain the required data?Plz help out.
    Thanks.

    Hi
    Thanks for the details.
    Your workflow configuration is quite strange.
    <u>Couple of questions to ask here :-></u>
    <b>1) what's your business requirement ?
    2) which SRM version are you using ?
    3) which SRM scenario have you implemented ? (Classic/Extended Classic/Standalone)
    4) What do yo mean by "I am thinking of creating a org structure with each row of criteria as one position say manager1, manager2 etc.". Are you talking about Workflow Configuration using PPOMA_BBP Transaction ? Are you looking for Functional aspect or you need to implement by coding (Technical Aspect) ?
    5) I remember you told in your earlier reply that you are looking for Technical aspect by creating a function module inside N-Level Approver BADI (BBP_WFL_APPROV_BADI in SE18). Have you completed that part ? 
    6) Can you maintain a custom table (Z table) and maintain the conditions there and based on the Shopping cart
    values, we can manipulate the list of approvers decided.
    7) What about functional part ? Are you taking care of both Functional and technical aspects of the Workflow configuartion in this case ?</b>
    Please send me the detailed information.
    Hope this will help.
    Regards
    - Atul

  • TS3276 can't download mail from windows live account.  I have deleted and re-set up the account but still won't work.  I can go online and access with no problem or get mail from other apple devices.

    Not able to get mail from windows live account.

    Firefox can find plugins in several locations, but Firefox 21 changed the location of the "shared" plugin folder so older installers like the Microsoft Windows Media Plugin no longer drop the DLL file in the correct location.
    There apparently are two ways to address this:
    (1) Change a Firefox preference so that Firefox checks the old location. Here's how:
    (i) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (ii) In the filter box, type or paste '''plugins''' and pause while the list is filtered
    (iii) Double-click '''plugins.load_appdir_plugins''' to switch its value from false to true.
    This will take effect after you restart Firefox.
    (2) Copy the plugins folder to the new location. Here's how on Win 7 64-bit:
    Open a Windows Explorer window to:
    C:\Program Files (x86)\Mozilla Firefox
    Right-click and copy the '''Plugins''' folder
    Double-click the '''browser''' folder to open it
    Right-click and paste
    Right-click the new copy of '''Plugins''' and rename it to '''plugins'''
    After restarting Firefox, the plugins in that folder should now be available.
    ''Edit: I suggest just doing #1.''

  • Help with getting values from request. Very Strange!!

    Hello,
    My very strange problem is the following.
    I have created three dynamic list boxes. When the user select
    the first list box, the second becomes populated with stuff
    from a database. The third becomes populated when the second
    is selected. Now, I have used hidden values in order for
    me to get the selected value from the first listbox. The
    following code is my first listbox:
    <SELECT NAME="resources" onChange="document.hiddenform.hiddenObject.value = this.option [this.selectedIndex].value; document.hiddenform.submit();">
    <OPTION VALUE =""> Resource</OPTION>
    <OPTION VALUE ="soil"> Soil </OPTION>
    <OPTION VALUE ="water"> Water </OPTION>
    <OPTION VALUE ="air"> Air </OPTION>
    <OPTION VALUE ="plants"> Plants </OPTION>
    <OPTION VALUE ="animals"> Animals </OPTION>
    </SELECT>
    I use the getRequest method to get the value of hiddenObject.
    At this time I am able to get the value of hiddenObject to populate
    the second list box.
    But, when the user selects an item from the second list box
    and the second form is also submitted,
    I lose the value of hiddenObject. Why is this??
    The code to populate my second listbox is the following:
    <SELECT NAME ="res_categories" onChange="document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value; document.hiddenform2.submit(); ">
    <OPTION VALUE ="" SELECTED> Category</OPTION>
    Here I access a result set to populate the list box.
    Please help!!

    Form parameters are request-scoped, hence the request.getParameter("hiddenObject"); call after the submission of the second form returns a null value because the hiddenObject parameter does not exist within the second request.
    A solution would be to add a hiddenObject field to your second form and alter the onChange event for res_categories to read
    document.hiddenform2.hiddenObject.value=document.1stvisibleformname.resources.option[document.1stvisibleformname.resources.selectedIndex].value;
    document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value;
    document.hiddenform2.submit();You will then come across a similar problem with your third drop-down if indeed you need to resubmit the form...
    A far better approach would be to create a session scoped bean, and a servlet to handle these requests. Then when the servlet is called, it would set the value of the bean property, thus making it available for this request, and all subsequent requests within the current session. This approach would eliminate the need for the clunky javascript, making your application far more stable.

  • Problem retrieving javabean instance from request in JSP

    I am using WSAD and I created a javabean called confirmBean in default package which contains two private properties fname, lname and public setters and getters
    In a servlet I placed values in the bean, then placed the bean in a request and then forwarded to confirm.jsp
    confirmBean cb = new confirmBean();
    cb.setFname("testing");
    req.setAttribute("mybean", cb);     
    req.getRequestDispatcher("/confirm.jsp").forward(req,res);
    Here is my JSP, I used java syntax for retrieving javabean:
    <HTML>
    <HEAD>
    <TITLE>confirm.jsp</TITLE>
    </HEAD>
    <%@ page
    language="java"
    contentType="text/html; charset=ISO-8859-1"%>
    <%@ page import="confirmBean"%>
    <BODY>
    <% confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); %>
    <%= myBean.getFname() %>
    </BODY>
    </HTML>
    and here is the error i am getting when executing:
    Error 500: Unable to compile class for JSP c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\localhost\server1\Test\TestWeb.war\_confirm.java:3: '.' expected import confirmBean; ^ An error occurred at line: 11 in the jsp file: /confirm.jsp Generated servlet error: c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\localhost\server1\Test\TestWeb.war\_confirm.java:78: cannot resolve symbol symbol : class confirmBean location: class org.apache.jsp._confirm confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); ^ An error occurred at line: 11 in the jsp file: /confirm.jsp Generated servlet error: c:\testWorkspace\.metadata\.plugins\com.ibm.etools.server.core\tmp0\cache\localhost\server1\Test\TestWeb.war\_confirm.java:78: cannot resolve symbol symbol : class confirmBean location: class org.apache.jsp._confirm confirmBean myBean = (confirmBean)request.getAttribute("MYBEAN"); ^ 3 errors
    Please help!!!!

    1 - Put your bean in a proper package. As of Java1.4 classes in the default package are not visible :
    http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=c85f07c1ce8f344d787b7a5146d68:WuuT?bug_id=43615752 - As a matter of style, class names should always start with a capital letter. ie ConfirmBean
    3 - Rather than declaring the bean, and retrieving it, from the request manually, have a useBean tag:
    <jsp:useBean id="MYBEAN" class="com.mypackage.ConfirmBean" scope="request"/>
    of course the id has to be the same as the attribute in scope.
    Hope this helps,
    evnafets

  • Getting attributes from a XML File, stored in Oracle

    Hello,
    my problem is the following
    I have a xml file that looks like that:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <root path="H:\musik">
    <directory name="Bj�rk - Homogenic" path="H:\musik\Bj�rk - Homogenic">
    <file album="Homogenic" artist="Bjoerk" comment=""
    completename="Bjoerk - Hunter" genre="Techno"
    name="01 - Hunter.mp3"
    path="H:\musik\Bj�rk - Homogenic\01 - Hunter.mp3"
    title="Hunter" year="1997"/>
    <file album="Homogenic" artist="Bjoerk" comment=""
    completename="Bjoerk - Joga" genre="" name="02 - Joga.mp3"
    path="H:\musik\Bj�rk - Homogenic\02 - Joga.mp3" title="Joga" year="1994"/>
    </directory>
    <directory name="Blank & Jones - In Da Mix" path="H:\musik\Blank & Jones - In Da Mix">
    <file album="In da Mix" artist="Blank & Jones" comment=""
    completename="Blank & Jones - On a journey (Intro)"
    genre="Dance" name="01 - On a journey (Intro).mp3"
    path="H:\musik\Blank & Jones - In Da Mix\01 - On a journey (Intro).mp3"
    title="On a journey (Intro)" year="1999"/>
    <file album="In da Mix" artist="Blank & Jones" comment=""
    completename="Blank & Jones - Cream" genre="Dance"
    name="02 - Cream.mp3"
    path="H:\musik\Blank & Jones - In Da Mix\02 - Cream.mp3"
    title="Cream" year="1999"/>
    </directory>
    </root>
    This file I have stored in Oracle as table of XML Type.
    Now I have build a little Java Programm, that displays the XML File like the File structure in the Windows Explorer.
    I want, when I choose a file in the File structure, that the ID3 Informations like album artist a.s.o. can be displayed. My problem is, I couldn't get these informations e.g. in an array from the database. Any suggestions how I could realize this in Java?
    Thx for any comments
    Max

    Try this:
    select extract(xmltypefieldname, '//xpath/field@attribute').getStringVal() from yourtable where yourwhereclause
    You can also select elements that match certain attributes by using a predicate such as field[@attr = myval][@attr2 = myval2]...
    Hope this helps.

  • How to get attribute from select

    Hello
    I have a problem getting the value from my select-field from my form in my servlet.
    I can get the values from the textareas and the textfileds but not from my select. If i mail the same form i get the selected value, but not when i try to get this in my servlet.
    To get the other values i use:
    String subcategory = (String) request.getAttribute("subcategory");
    Is there any other way to get the values from select (or radiobuttons) ?

    don't you think you should use request.getParameter("XXX")?
    And if your can select multiple items , then use request.getParameters("SSS"). Note that this method return arrray of String.

  • Having problems connecting getting results from MySQL

    Hi,
    I'm trying to learn some aspects of J2EE but i'm a bit
    stuck with EJB and i'm not sure what is going wrong so that's why i'm here :)
    What I want to do is very simple.
    I have a working MySQL database "musiccatalog" and I want to query it using any sort of client so to do that
    I create an Entreprise Application using netBeans 4.1
    Then I create a new CMP Bean called Album.
    I need something simple to test on so I have only one CMP Bean.
    My Album CMP Beans contains following CMP fields albumId, artistId, name, releaseDate, insertionTime.
    I also have a bunch of methods for LocalInterface: getters, setters, finders, and create() method.
    I don't need to add anything or write in the code cause it is generated by the IDE (netBeans 4.1)
    So my Album CMP Bean is written and I deploy project to see if all works fine. It works. My EJB-Module and Web-Module are deployed on the server (Sun Application Server 8).
    Next I create a new SessionBean called AlbumFacade that will access my CMP bean.
    I will have to add a lookupAlbumBean() method that will return a LocalHome interface, I also add a private variable of Type AlbumLocalHome. This variable is intialized in ejbCreate() method using the lookAlbumBean() method.
    Now it's time to add a business method to my SessionBean.
    I create a new buisness method public String getAlbumInfo()
    public String getAlbumInfo(int idAlbum) throws javax.ejb.FinderException {
    ejb.AlbumLocal albumL = albumLH.findByPrimaryKey(new Integer(idAlbum));
    return albumL.getAlbumName();
    so in this method i will get a reference to albumL interface and i will ask it to return the albumName of an album.
    So at this moment i'm done with Beans :)
    I redeply the app and it is redeplyed successfully.
    Now to test my beans i write a client. It'll be a servlet.
    What I need to do next is to create a ServiceLocator in my WebModule. This ServiceLocator will be used in the Servlet to lookup the remote interface of the AlbumFacade SessionBean.
    MyServlet will output a form with a textfield and a submit button where the user (me) types a number.
    If the servlet receives albumId parameter it'll look up the remote AlbumFacadeRemote interface and then i'll call the buisness logic of the SessionBean ( getAlbumInfo())
    and at this moment I should reach what I wanted but....
    The Application deploys and after I enter a number I got a vert nice StackTrace like this
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 9998 Maybe; nested exception is:
         org.omg.CORBA.TRANSACTION_ROLLEDBACK: vmcid: 0x2000 minor code: 1806 completed: Maybe
         com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:207)
         com.sun.corba.ee.impl.javax.rmi.CORBA.Util.wrapException(Util.java:651)
         javax.rmi.CORBA.Util.wrapException(Util.java:279)
         com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:177)
         com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
         ejb._AlbumFacadeRemote_DynamicStub.getAlbumInfo(_AlbumFacadeRemote_DynamicStub.java)
         web.AlbumServlet.processRequest(AlbumServlet.java:55)
         web.AlbumServlet.doPost(AlbumServlet.java:81)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
         java.security.AccessController.doPrivileged(Native Method)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    note The full stack trace of the root cause is available in the Sun-Java-System/Application-Server logs.
    and it happens when the application queries the database.
    And unfortunately I don't see what may be wrong. If I do the same with a pointbasde sample database everything works fine.
    I tried to connect to MySQL via JConnector and also via jdbc:odbc bridge but i got still the same error.
    It drives me really mad 'coz I don't know what I do wrong.
    I can connect to database. But then something goes wrong.
    Can somebody give me an idea of what maybe wrong?
    Thanks :)

    Hail!!
    In fact, the problem IS in your PHP script.
    $senderEmail = $_POST['eMail'];
    $senderEmail = stripslashes($eMail);
    The last one should be:
    $senderEmail = stripslashes($senderEmail);
    PS:
    Next time, put your code inside formating tags...
    It will be easy for people to read your question and will improve the chances that someone answer it.

  • How to get org_id from request?

    Hello all,
    Any ideas on how I can get the org_id from a concurrent_request id?
    To put it a little differently, I have a concurrent_request_id, and would like to know which org it was submitted from?
    Thanks,

    Forgive me as I am trying to be more specific with out being ambiguous, but here goes...
    Example data would be request_id of 12345678.
    And the expected output would be org_id.
    I would like to do something like
    "select org_id from fnd_concurrent_requests where request_id = 12345678"
    But clearly that is not an option. So again I am looking to see what org the request was submitted from?
    Thanks in advance.

  • Getting bean from request scope

    Hi,
    I am new to JSF and unfortunately I am running into a problem that I am not entirely sure about. I look in other forums and what I am doing looks right but I am not getting the desired result.
    In my faces-config.xml file I have a managed bean defined as follows:
    <managed-bean>
        <managed-bean-name>LogIn</managed-bean-name>
        <managed-bean-class>lex.cac.tables.RefUsers</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>I then have a log on page with a form which contains a user name and password field. The tags are defined as
    <h:inputText immediate="false" value="#{LogIn.username}" /> (for username) and
    <h:inputSecret immediate="false" required="true"
                                   value="#{LogIn.password}" /> (for password)
    When I submit the form the web app navigates to a jsp page which attempts to do validation against a database.
    The first step though is retrieving the object which is suppose to be in request scope.
    I attempt the following but I get back null which causes a NullPointerException. Why can't if find the bean?
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    Map params         = ec.getRequestParameterMap();
    params.get("LogIn");  //null is returned hereWhat am i doing wrong? Can someone please help.
    Thanks in advance,
    Alex.

    Something like that:
    FacesContext fc = FacesContext.getCurrentInstance();
    RefUsers LogIn = (RefUsers)fc.getApplication().createValueBinding("#{LogIn}").getValue(fc);
    String username = LogIn.getUsername();
    String password = LogIn.getPassword();

  • How to get attribute from xml file

    I managed to grab all the info from xml, except the "url" attribute in <image type="poster" url="" size="mid" .../>. Any ideas?
    import java.io.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import java.net.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class XmlParser {
         ArrayList<Movie> myMovies;
         Document dom;
         public XmlParser(){
              //create a list to hold the movie objects
              myMovies = new ArrayList<Movie>();
         public void runExample(String adr, String tagName) {
              parseXmlFile(adr);
              parseDocument(tagName);
              printData();          
         private void parseXmlFile(String adr){
              //get the factory
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              try {               
                   //Using factory get an instance of document builder
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   //parse using builder to get DOM representation of the XML file
                   URL xmlUrl = new URL(adr);
                   InputStream in = xmlUrl.openStream();
                   dom = db.parse(in);               
              }catch(ParserConfigurationException pce) {
                   pce.printStackTrace();
              }catch(SAXException se) {
                   se.printStackTrace();
              }catch(IOException ioe) {
                   ioe.printStackTrace();
         private void parseDocument(String tagName){
              //get the root elememt
              Element docEle = dom.getDocumentElement();
              //get a nodelist of <movie> elements
              NodeList nl = docEle.getElementsByTagName(tagName);
              if(nl != null && nl.getLength() > 0) {
                   for(int i = 0 ; i < nl.getLength();i++) {
                        //get the movie element
                        Element el = (Element)nl.item(i);
                        //get the Movie object
                        Movie mov = getMovie(el);
                        //add it to list
                        myMovies.add(mov);
          * I take an movie element and read the values in, create
          * an Movie object and return it
          * @param movE
          * @return
         private Movie getMovie(Element movE) {
              String title = getTextValue(movE, "original_name");
              String year = getTextValue(movE, "released");
              String imdbId = getTextValue(movE, "imdb_id");
              double score = getDoubleValue(movE, "score");
              String overview = getTextValue(movE, "overview");
              String poster = movE.getAttribute("url");
              Movie mov = new Movie(title, year, imdbId, score, overview, poster);
              return mov;
         private String getTextValue(Element ele, String tagName) {
              String textVal = null;
              NodeList nl = ele.getElementsByTagName(tagName);
              if(nl != null && nl.getLength() > 0) {
                   Element el = (Element)nl.item(0);
                   textVal = el.getFirstChild().getNodeValue();
              return textVal;
          * Calls getTextValue and returns a int value
          * @param ele
          * @param tagName
          * @return int
         private int getIntValue(Element ele, String tagName) {
              //in production application you would catch the exception
              return Integer.parseInt(getTextValue(ele, tagName));
          * Calls getTextValue and returns a double value
          * @param ele
          * @param tagName
          * @return double
         private double getDoubleValue(Element ele, String tagName) {
              return Double.parseDouble(getTextValue(ele, tagName));
          * Iterate through the list and print the
          * content to console
         private void printData(){
              System.out.println("Total Movies: " + myMovies.size());
              Iterator it = myMovies.iterator();
              while(it.hasNext()) {
                   System.out.println(it.next().toString());
         public static void main(String[] args){
              //create an instance
              XmlParser xp = new XmlParser();
              //call run example
              xp.runExample("http://api.themoviedb.org/2.1/Movie.search/en/xml/apikey/Fight+Club+1999", "movie");
    }Here is the example xml file I used
    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
      <opensearch:Query searchTerms="Fight Club 1999"/>
      <opensearch:totalResults>1</opensearch:totalResults>
      <movies>
        <movie>
          <score>8.383284</score>
          <popularity>3</popularity>
          <translated>true</translated>
          <adult>false</adult>
          <language>en</language>
          <original_name>Fight Club</original_name>
          <name>Fight Club</name>
          <alternative_name>El Club de la Lucha</alternative_name>
          <type>movie</type>
          <id>550</id>
          <imdb_id>tt0137523</imdb_id>
          <url>http://www.themoviedb.org/movie/550</url>
          <votes>62</votes>
          <rating>8.4</rating>
          <certification></certification>
          <overview>A lonely, isolated thirty-something young professional seeks an escape from his mundane existence with the help of a devious soap salesman. They find their release from the prison of reality through underground fight clubs, where men can be what the world now denies them. Their boxing matches and harmless pranks soon lead to an out-of-control spiral towards oblivion.</overview>
          <released>1999-09-16</released>
          <images>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-original.jpg" size="original" width="1000" height="1500" id="4bc908ab017a3c57fe002f75"/>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-mid.jpg" size="mid" width="500" height="750" id="4bc908ab017a3c57fe002f75"/>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-cover.jpg" size="cover" width="185" height="278" id="4bc908ab017a3c57fe002f75"/>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-thumb.jpg" size="thumb" width="92" height="138" id="4bc908ab017a3c57fe002f75"/>
            <image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-original.jpg" size="original" width="1280" height="720" id="4bc908ab017a3c57fe002f71"/>
            <image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-poster.jpg" size="poster" width="780" height="439" id="4bc908ab017a3c57fe002f71"/>
            <image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-thumb.jpg" size="thumb" width="300" height="169" id="4bc908ab017a3c57fe002f71"/>
          </images>
          <version>73</version>
          <last_modified_at>2010-09-11 14:33:06</last_modified_at>
        </movie>
      </movies>
    </OpenSearchDescription>

    pvujic wrote:
    Thanks, but how can I "fetch" the url from the image element?You've got to first get to the image element. But based on what you've posted though, with a little more coding, you should be able to succeed. Just give it a try! :)

  • Get IP from request caller

    We are working on a POC based on user management and Fusion 11.
    We want to include an audit service which stores the following data from the external request:
    1. client application (ex: browser, SOAP UI or any other application)
    2. IP caller
    3. operation / port type requested on exposed service
    Can anyone address us on how to retrieve these data from the external service request?
    Thanks in advance
    Alessandro

    First of all, thanks for your help.
    Second, I've investigated deeper on XPATH and Mediator's Assign values function. I guess this was where you tried to point me.
    Although I still haven't managed to work with the expression you've given me, I was wondering how I can access those properties (service, transport) from the Expression builder GUI.
    The error I get from the Application server is
    SEVERE: Exception while processing deferred message due to ORAMED-02103:[Invalid assign expression]Invalid assign expression "<copy target="$out.LogCollection/top:LogCollection/top:Log/top:whichClient" value="$inbound/ctx:transport/ctx:request/tp:headers/http:User-Agent/text()" xmlns:top="http://xmlns.oracle.com/pcbpel/adapter/db/top/Audit" xmlns="http://xmlns.oracle.com/sca/1.0/mediator"/>
    ".Possible Fix:Check assign xpath expression for any syntax error. If there are any syntax error, correct the xpath expression.
    22-Nov-2009 22:10:19 racle.tip.mediator.common.listener.DBWorker process SEVERE: Enququeing to Error hospital successful...
    Do I have to configure something on the Mediator component, such as an external schema?

  • Where do I get attributes from in AuditLog Report

    Hi,
    Here is my AuditLog Report
    defvar name='attrMap'>
    <Map>
    <MapEntry key='attr.office' value='Office'/>
    <MapEntry key='attr.lastname' value='Last Name'/>
    <MapEntry key='attr.custid' value='Cust-ID'/>
    <MapEntry key='attr.action' value='Action'/>
    <MapEntry key='timestamp' value='Date'/>
    <MapEntry key='attr.actionOnUser' value='Action on User'/>
    <MapEntry key='attr.station' value='Station'/>
    <MapEntry key='attr.mailrouting' value='Mail Office Code'/>
    <MapEntry key='attr.firstname' value='First Name'/>
    <MapEntry key='attr.initials' value='Middle Initial'/>
    </Map>
    </defvar>
    <defvar name='attrList'>
    <List>
    <String>attr.office</String>
    <String>attr.lastname</String>
    <String>attr.custid</String>
    <String>attr.action</String>
    <String>timestamp</String>
    <String>attr.actionOnUser</String>
    <String>attr.mailrouting</String>
    <String>attr.firstname</String>
    <String>attr.initials</String>
    <Field name='audit.attrMapField'>
    <Expansion>
    <ref>attrMap</ref>
    </Expansion>
    </Field>
    Not sure where do I get the values from? there is no attribute named attr.custid etc.. Where can I find these. Any help would be appreciated. Basically I have to add an attribute for user's job title. When I define attribute attr.title, no value is populated in the AuditLog Report. Any help would be appreciated. Thanks in advance
    Edited by: 994616 on Mar 18, 2013 4:29 PM

    My photo icon on icloud.com did not appear until I went to my device (ipad in my case) and went to settings...Photos and Camera and toggle on iCloud Photo and Library (Beta) then refresh the icloud.com page.

Maybe you are looking for