In WL6.1 request.getParameter returns NULL for URL parameters that exist

          With the following URL, I get different results between WebLogic 4.5.1 and WebLogic
          6.1:
          http://phx-kmccarthy.medspecialists.net/tsweb/ParametersTest.jsp?apple=macintosh&tree&dog&country=USA
          Weblogic 6.1 returns:
          query string = apple=macintosh&tree&dog&country=USA
          apple = macintosh
          tree = null
          dog = null
          country = USA
          WebLogic 4.5.1 returns:
          query string = apple=macintosh&tree&dog&country=USA
          apple = macintosh
          tree =
          dog =
          country = USA
          here is the jsp...
          <%--
          * ParamtersTest.jsp which shows that empty parameters are ignored in WebLogic
          6.1
          --%>
          <%
          String apple, tree, dog, country;
          apple = request.getParameter("apple");
          tree = request.getParameter("tree");
          dog = request.getParameter("dog");
          country = request.getParameter("country");
          out.println("<br>query string = " + request.getQueryString());
          out.println("<br>apple = " + apple);
          out.println("<br>tree = " + tree);
          out.println("<br>dog = " + dog);
          out.println("<br>country = " + country);
          %>
          From the documentation on the getParameter() method:
          Returns the value of a request parameter as a String, or null if the parameter
          does not exist.
          In my opinion, not existing and being empty are different. Also, every other web
          application environment we've dealt with (including WebLogic 4.5.1) treats them
          as different. If the parameter doesn't have a value, (i.e. ...&tree&dog&...) then
          getParameter() returns the empty string, not null.
          As a result of this we have JSPs that break when running on 6.1.
          

Found the solution at last. Tomcat servlet container can't handle the chunked transfer-encoding that the J2ME Wireless Toolkit uses when you call outputstream.flush() in midlet. Using outputstream.close() instead of outputstream.flush() will avoid this problem for small requests. For all the codes in the articles on Http Post in Wireless Forum, don't use outputstream.flush() and it will run perfectly - Servlet's request.getParameter(parameterName) will work fine in doPost method.

Similar Messages

  • In Portal, request.getparameter return NULL (Sample Monthcalendar)

    I used the sample monthcalendar. When i used it without integrated in portal, i can change month by month with ">>" button.
    In the JSP File, there is a call to the P_CALDATE parameter
    String l_inputDate = request.getParameter("P_CALDATE"); // Input Date.
    When i put this JSP file as an URL Portlet, i can't navigate month by month. the function request.getParameter("P_CALDATE") return NULL, but in the URL i have the parameter:
    http://hddms220.cg63.fr/servlet/page?_pageid=54,58,56&_dad=portal30&_schema=PORTAL30&P_CALDATE=2002-05-01.
    Someone have an idea
    Thanks in advanced

    I have tested the sample with JSERV, and all works fine.
    But if i wan't use OC4J/ORION to display a portlet how can i do it.
    Thanks in advanced

  • Request.getParameter returns null - Converting webapp from Tomcat to oc4j

    I support a simple web app that passes arguments via url context variables. For some reason it does not work in OC4J. When I use request.getContextPath() I see that the URL string only contains the webapps name, not the whole URL with parameters set.
    BTW it is an OC4J cluster

    *Name:             index.jsp
    *Function:         This page is 1st url for WebApp
    *Information:      This page is used as the home page for this application.
    *Version:          1.0 (created on 2005-06-06)
    * 2.0 052406 pge
    %>
    <%@ page pageEncoding="UTF-8"%>
    <%@ page import="com.hp.itsm.api.*" %>
    <%@ page import="com.hp.itsm.api.interfaces.*" %>
    <%@ page import="java.text.Collator" %>
    <%@ page import="java.util.*"%>
    <%@ page contentType="text/html; charset=utf-8" %>
    <%@ include file="include/variables_initialize.jsp" %>
    <%@ include file="include/methods_global.jsp" %>
    <%@ include file="include/methods_servicedesk.jsp" %>
    <%
    String login = request.getParameter("u");
    String xxx = request.getContextPath();
    //Service Call objects
    ApiSDSession SDsession = null;
    IPerson[] personList = null;
    IAccount accountRequester = null;
    Boolean bError = Boolean.FALSE; //Default to no errors found
    List errMsgList = new ArrayList(); //Array of error messages
    //Get account information
    accountRequester = getAccount(SDsession, login);
    if (accountRequester == null) {
    bError = Boolean.TRUE;
    errMsgList.add("Could not retrieve the accountRequester.");
    }

  • In JSP pages request.getParameter returns null

    There are two jsp's,the first JSP has 1 textbox inside the form tag.We input the values in the textbox and submit.
    Code :Ist jsp
    <BODY>
    <HEAD>
    function validate()
    document.add.submit();
    </HEAD>
    <FORM name="add" method="post" action=/dir/two.jsp" >
    <TABLE width="37%" border="0" align="center" class="c4f3">
    <TR>
    <TD class="c4">Rating</TD>
    <TD><input type=text name="rating"></TD?
    </TR>
    <TR>
    <TD align=center><INPUT type="button" name="submitadd" value="Submit" onClick="validate()" </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    After the submit it goes to the 2nd JSP page .
    code:2nd Jsp
    <%
    String Rating=request.getParameter("rating");
    out.println(" Rating "+Rating);
    %>
    The 2nd JSP pages gets the values by request.getParameter.When I use method='post' in Ist JSP ,even if I enter values in the textbox, it prints null. But when I give method="get" , it prints the value.
    Pls let me know if there is any problem in the code or its the problem due to webserver configuration.Also suggest the solution to over come this problem.
    Thanks

    If I'am right you have misplaced the opening body-tag of your first jsp-page.
    The opening body-tag should follow after the closing head tag .
    The structure of your HTML-code should look like this:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>

  • Conversion agent; CMException: Request IF_EXEC2 returned null

    Hi all,
    "CMException: Request IF_EXEC2 returned null"
    I'm trying to use a conversion agent serializer to ouput a file from PI 7.1 and am getting the above message in the receiver comm. channel monitor.  No idea what it means.
    This is my first use of conversion agent, so I'm not sure that everything is correctly in place, but the Conversion agent console set-up test works, and I've followed all the blogs I can find so I'm reasonably happy with it.
    Executing the script from the CM console gives me the transformation I want, so my serializer seems OK.
    The PI configuration scenario works fine if I use a receiver channel without the CMTransform bean module (i.e I get an xml file output), so that's OK.
    I get nothing in the NWA logs.
    I'm running out-of-process (64 bit PI system) and the console config looks OK per the admin guide.
    Any ideas folks ?
    Regards,
    Guy

    That's an odd thing.
    When I run it in studio, it completes without any obvious error, but there's no "results" file.
    We had initially installed the 32 bit version (when I was on XI 3.0), and I ran the studio on the XI machine and the results file showed in studio.  But now, my studio is on my PC (not the PI machine).
    However, all that aside, when I execute the CM_Console with my project I get exactly the output I expect...so I'm sure that the serializer is OK.

  • Getnode returned null for uri error for caldav server

    Hello,
    I am trying to install the Oracle UCS ( SUN 7 update 2 ) server.
    https://wikis.oracle.com/display/CommSuite7U2/Communications+Suite+on+a+Single+Host+%28Linux%29#CommunicationsSuiteonaSingleHost%28Linux%29-InstallingtheExample
    So far, I have successfully:
    Checked the installation requirements
    Installed Communications Suite 7 Update 2 Software
    Installed and Configured the Directory Server
    Prepared the Directory under ( Configuring Communications Suite Components )
    Configured Delegated Administrator and Communications CLI
    Configured Messaging Server
    Configured MYSQL Server
    Configured Calendar Server
    I have just installed a caldav server. I checked that it was enabled by running:
    # asadmin list-components -p <admin-port> --type=web
    davserver <web-module>
    Command list-components executed successfully.
    # asadmin show-component-status -p <admin-port> davserver
    Status of davserver is enabled.
    Command show-component-status executed successfully.
    that was from this page:
    https://wikis.oracle.com/display/CommSuite7RR92909/Calendar+Server+7+Troubleshooting
    In Firefox, I try to hit the suggested pages under "Testing Calendar accounts". However, this errors out every time for me.
    http://domain.com/davserver/dav/h/myDomain.com/myusername/calendar
    wheremyDdomain.com is my actual domain that I will not list here
    and myUsername is my actual username which I will not list here
    ( I edited both of these in the logs below )
    I checked my log in /var/opt/sun/comms/davserver/logs:
    INFO [2012-02-11T11:46:02.729-0500] <...DavServer.<init>> Server Startup succeeded
    INFO [2012-02-11T11:46:02.730-0500] <...DavServer.loadBackend> Loading backend defaultbackend with backendid defaultbackend
    INFO [2012-02-11T11:46:02.730-0500] <...DavServer.loadBackend>      JDBC JNDI Name = jdbc/defaultbackend
    INFO [2012-02-11T11:46:09.033-0500] <...DavServer.loadBackend> Loading backend ischedulebackend with backendid ischedulebackend
    INFO [2012-02-11T11:46:09.033-0500] <...DavServer.loadBackend>      JDBC JNDI Name = jdbc/ischedulebackend
    INFO [2012-02-11T11:46:09.427-0500] <...DavServer.loadBackends> iSchedule enabled
    INFO [2012-02-11T11:46:09.439-0500] <...DavServer.loadBackends> modified ischedule collection at /ischedule/
    INFO [2012-02-11T13:33:18.967-0500] <...URIInfoManagerImpl.getEntryFromSearchFilter> found 0 corresponding to: (uid=caldav)
    INFO [2012-02-11T13:33:59.844-0500] <...URIInfoManagerImpl.getEntryFromSearchFilter> found 0 corresponding to: (uid=caldav)
    FINE [2012-02-11T13:42:39.157-0500] <...DavServerServlet.service> [REQ] GET /davserver/browse/h/myDomainName/myUserName/calendar 127.0.0.1 myDomainName
    FINE [2012-02-11T13:42:39.808-0500] <...LDAPSingleHostPool.getConnection> got connection from getConnection() for pool Pool number:0. Host=myDomainName
    FINE [2012-02-11T13:42:41.441-0500] <...LDAPSingleHostPool.getConnection> got connection from getConnection() for pool Pool number:0. Host=myDomainName
    FINE [2012-02-11T13:42:41.460-0500] <...LoginModuleHelper.checkIfUserInAdminGroup> user: admin; isMemberOf = cn=Service Administrators, ou=Groups, o=isp
    FINE [2012-02-11T13:42:41.684-0500] <...DavBrowserServlet.service> Got a non standard condition: getNode returned null for uri /davserver/browse/h/myDomainName/myUserName/calendar
    FINE [2012-02-11T13:42:41.684-0500] <...DavServerServlet.service> [RES] [404] Command execution time: 2.527 secs
    I can hit this page from the browser:
    http://myDomainName:4848
    From my understanding, that is the admin port. That brings up the GlassFish server admin page.
    I do not remember creating a calendar account anywhere is my first thought. I followed the example deployment step by step so far and nowhere does it have me create a calendar user account. So, maybe there is no account at this point?
    So, my first question would be:
    How can I verify that I have a calendar account to begin with? ( or is this what I am doing by trying to log into the sites suggested under 'Test Calendar Accounts').
    My next question would be:
    What does this error mean: "getnode returned null for uri error for caldav server"?
    Spin off question from that:
    What should I do to fix that error?
    Thanks in advance!

    I did not put a slash at the end of the uris I was testing
    http://myDomain.com:80/davserver/browse/h/myDomain/myUserName/calendar
    http://myDomain.com:80/davserver/dav/h/myDomain/myUserName/calendar
    Once I put the slash at the end of the uri, the configuration page appeared and the error was not displayed about getNode anymore:
    http://myDomain.com:80/davserver/browse/h/myDomain/myUserName/calendar/
    http://myDomain.com:80/davserver/dav/h/myDomain/myUserName/calendar/

  • Hibernet query returns null for XMLTYPE data when I use oracle type4 driver

    Hi,
    I am using Oracle type-4 driver, My hibernet query returns null for data type XMLTYPE. But when I use BEA type -4 driver its working fine. Please help me to retrive XMLTYPE data using oracle-4 driver through hibernet query.
    Thanks in advance.
    regards,
    Amaresh

    Hi,
    I am using Oracle type-4 driver, My hibernet query returns null for data type XMLTYPE. But when I use BEA type -4 driver its working fine. Please help me to retrive XMLTYPE data using oracle-4 driver through hibernet query.
    Thanks in advance.
    regards,
    Amaresh

  • Request.getParameter is NULL from window.open form submit

    Hi all,
    We have one portlet application where a jsp page has a link which opens as a child window using the window.open function in javascript.
    It has a form and some textboxes with a save submit button.When the save button is clicked the portlet processAction is called but when i try to set the renderrequest all the request.getParameters are null .I have tried both the ActionRequest and HttpServletRequest and both have nul values.
    As a result me Save is failing since the request.getparametrs are null.I added the "save" as part of form action URL and its getting passsed but the other, i am unable to fetch.
    My Form action is : <form name="saveEntries" id="saveEntries" action="<portlet:actionURL secure="true"/>&action=save&_pageLabel=ABC" method="post">
    My process action code is :
    Enumeration<String> parameters = request.getParameterNames();
              while(parameters.hasMoreElements()) {
                   String parameter = parameters.nextElement();
                   String[] values = request.getParameterValues(parameter);
                   if(values != null && values.length > 1){
                        response.setRenderParameter(parameter, values);
                   } else {
                        response.setRenderParameter(parameter, request.getParameter(parameter));
                        if(request.getParameter(parameter)!=null && "save".equalsIgnoreCase(request.getParameter(parameter))){
                             HttpServletRequest httpRequest = (HttpServletRequest) request.getAttribute("javax.servlet.request");
                             Enumeration parameterNames = httpRequest.getParameterNames();
                             Enumeration<String> httpparameters = parameterNames;
                             while(httpparameters.hasMoreElements()) {
                                  String httpparameter = httpparameters.nextElement();
                                  String[] httpvalues = httpRequest.getParameterValues(httpparameter);
                                  if(httpvalues != null && httpvalues.length > 1){
                                       response.setRenderParameter(httpparameter, httpvalues);
                                  } else {
                                       logger.debug("----------------->:ApproveTime else processAction = :Getting HTTP :parameter:"+parameter);
                                       logger.debug("----------------->:ApproveTime else processAction = :Getting HTTP :request.getParameter(parameter):"+request.getParameter(parameter));
                                       response.setRenderParameter(httpparameter, httpRequest.getParameter(httpparameter));
    Any help is highly appreciated.

    Hello,
    One potential reason why it isn't working for you is that the Java Portlet specifications (JSR168 and JSR286) don't allow URLs to be manipulated once they are created with a a portlet:xxxURL tag. The reason for this is that the portlet container needs to be able to rewrite the URLs to properly go back through the portal framework (or over WSRP if running the portlet remotely) and to encode all the parameters needed. The portal framework could even change it from a URL to a Javascript action, where simply appending extra "&paramName=someValue" onto the end of the generated URL won't work. So this:
    <form action="<portlet:actionURL secure="true"/>&action=save&_pageLabel=ABC" method="post">isn't legal by the portlet specification-- if you want to add parameters to the actionURL, you can by doing this:
    <form action="<portlet:actionURL secure="true"><portlet:param name="action" value="save"/><portlet:param name="_pageLabel" value="ABC"/></portlet:actionURL>" method="post">which will add the parameters to the URL in a way that will always work with the portal framework.
    One other thing to note- it looks like you're just trying to copy all of the action parameters in the request into render parameters in the response; this can be done much easier like this:
    response.setRenderParameters(request.getParameterMap());Kevin

  • Request.getCookies() returns null, not 0 length array

    (reposted from J2EE forum)
    Just upgraded to 9ias with Embedded OC4J and we were getting a NullPointerException.
    Our previous calls to request.getCookies() AKA http://java.sun.com/products/servlet/2.1/api/javax.servlet.http.HttpServletRequest.html#getCookies()
    would return an an array of Cookie Objects or an array of zero length if there are no cookies.
    When we upgraded to 9ias, we got the NPE.
    Know why?
    OC4J implementation of HttpServletRequest doesn't return a zero length array, it returns a null object when there are no cookies!!!
    So we had to change our code to catch this.
    Not a big problem, and it's fixed now, but it was a problem nonetheless.
    Any reason/rationale for why this was done this way? Anyone? Bueller?

    Josh,
    According to Servlet Spec 2.3 (page 193) SRV 15.1.3.2 Methods for (HttpServletRequest SRV.15.1.3) getCookies() returns null if no cookies present. So we are compliant to the spec.
    regards
    Debu Panda
    Oracle That's strange that the NPE problem didn't occurr until deleting cookies on OC4J, then.
    Thanks for responding!

  • How to Change the return value for the parameters

    Hi, Can anyone help me with my problem?
    I have a parameter called "P1_Projects" defined in the HTMLDB page, on the report region, there are 2 buttons, one is "Go" button to submit the report on the screen, so user can preview the report, then another button "Export to PDF" can be clicked to generate the report using Oracle Report Services. The "Export to PDF" button will use the same set of parameters submitted for the "Go" button.
    So, the parameter "P1_Projects" is being used by these 2 buttons. and I have to pass a "%" wild card for "All Projects". To make the "Export to PDF" button work, I have to safe encode the return value for "%" to "%25" in order to pass the URL formula, but now my "Go" button doesn't work with "%25", it only recognize the "%" wild card.
    Is there a way to conditionally change the value depends which button is clicked?
    Any hint or help is highly appreciated!
    Hong

    try creating a plsql process which sets the P1_Projects item as required.
    in the plsql you can do:
    if :REQUEST = 'GO' then
    xxx
    else
    xxxx
    end if;
    set the condition to plsql expression:
    :REQUEST in ('GO', 'EXPORT')
    NB. the request value is usually set to the button name when a page is submitted from a button

  • Win32_NTLogEvent sometimes returns null for the Message field even though the event does contain a message

    This does not happen often but it does happen. We have an application that regular runs WMI queries to collect windows events. However, on a particular machine, on particular events, the windows event description that comes from the Win32_NTLogEvent.Message
    field is null. The event does indeed have a description and that can clearly be seen in the Event Viewer.
    One particular event that causes the problem is
    Event Type: Information
    Event Source: MsiInstaller
    Event Category: None
    Event ID: 1035
    Date:  4/21/2010
    Time:  8:51:53 AM
    User:  NT AUTHORITY\SYSTEM
    Computer: COMP201002
    Description:
    Windows Installer reconfigured the product. Product Name: 32 Bit HP BiDi Channel Components Installer. Product Version: 1.1.0.2. Product Language: 1033. Reconfiguration success or error status: 0.
    As you can see, the description exists. However, the field returned by WMI is null.
    Any way i can diagnose the problem to see what's going on? Is this a WMI bug?

    Hi markoueis, I suggest you first check these links for troubleshooting WMI as the issue can be caused by WMI on the particular machine:
    http://www.microsoft.com/technet/scriptcenter/topics/help/wmi.mspx
    How to troubleshoot WMI-related issues in Windows XP SP2
    http://support.microsoft.com/kb/875605
    You can also try restart WMI service and see the result. If this does not work, you can try the steps in the following article to rebuild repository:
    WMI Troubleshooting: The Repository on Vista / Server 2008
    http://blogs.technet.com/b/askperf/archive/2008/07/11/wmi-troubleshooting-the-repository-on-vista-server-2008.aspx
    Hope this helps!
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Why does getParameter("uri") returns null ???

    Hi !
    JAVA can be rather frustrating and I have run of of dukes. How about IOU ?
    Unfortunately none of the previous questions in the db shed light on my problem.
    I am trying to get at the "uri" and I have the following code fragment :
    package com.developer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.IOException;
    import java.io.PrintWriter;
    public class proptest extends HttpServlet
      public void doGet( HttpServletRequest req,  HttpServletResponse resp)
        throws ServletException, IOException
        PrintWriter out = resp.getWriter();
        out.println("Parameter Name: " + req.getParameter("uri"));
      public void init() throws ServletException
        // initialie the servlet here. Use ServletConfig object to get
        //    initialization parameters...
        ServletConfig config = getServletConfig();
        // ... more stuff ...
      }

    Hi!
    In case anyone stumbles upon this in the database, I worked aroung it by using req.getRequestURI().
    However I still do not know why getParameter() returns null. It would be useful e.g. if you want to display a list of all request params e.g.:
    // stub code follows...
    java.util.Enumeration enum = rea.getParameterNames();
    while (enum.hasMoreElements())
    String name = (String) enum.nextElement();
    System.out.println("Parameter "+name + " " + req.getParameter(name))
    ...For me, nope, all nulls. If it works for you , do tell me.
    Also if you look at the "bugs db" there seems to be a number of issues concerning getParameter().

  • Double type for request.getParameter

    Hi , I have a page to get a parameter which is a double
    I declare :
    Double score = request.getParameter("score") == null ? "" : request.getParameter("score");
    But I got error :
    incompatible types found; java.lang.String, required:java.lang.Double.
    Any idea how to solve this.
    I appreciated for any solution.
    Thank you very much in advance.

    request.getParameter always returns a string, so you'll have to convert it to a double.
    Something like this:
    String score = request.getParameter("score");
    Double score = (score == null) ? 0 : new Double(score);

  • Kff.where returns 'null'  and causes sql error - looking for a work around

    Hello,
    I am using BI 5.6.3 in EBS (11.5.10.2)
    I have created a kff.where as follows:
    <lexical
    type="oracle.apps.fnd.flex.kff.where"
    name="lp_location_where_clause"
    comment="Comment"
    application_short_name="OFA"
    id_flex_code="LOC#"
    id_flex_num=":lp_location_flex_structure"
    code_combination_table_alias="loc"
    segments="ALL"
    operator="BETWEEN"
    operand1=":p_location_low"
    operand2=":p_location_high"/>
    </lexicals>
    Everything works fine, as long as I have a values for the p_location_low and p_location_high. However, this is a parameter that comes in from a concurrent program and is optional. When the user doesn't pick a value, :p_location_low is the concatenated delimiters for the location '..'.
    When this runs, the kff.where is returning null which causes 'Invalid Relational Operation error' because 'AND null' is not valid.
    Warning in the log is :[091910_025232517][][STATEMENT] !!Warning: FlexAPI returns null for 'x_where_expression' lexical definition...
    Does anyone have a workaround for this since making the parameter required is not an option for my users?
    Thanks for reading.

    In your SQL*Plus session, make sure you
    SQL> set define offbefore trying to create the Java stored procedure. SQL*Plus assumes that any string that begins with an & is a substitution variable unless you tell it that you have no substitution variables (via set define off).
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • FrameGrabbingControl returns null

    In my code i want to grab a frame from a video and displey it in another window.But the problem is that " FrameGrabbingControl fgc =(FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");" returns null.Please help me by pionting out the error. Thanks in advance.
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.Thread;
    import java.util.*;
    import java.lang.*;
    import java.lang.String;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.IOException;
    import java.util.Properties;
    import javax.media.*;
    import java.applet.*;
    import javax.swing. *;
    import javax.swing.border. *;
    import javax.media.datasink. *;
    import javax.media.format. *;
    import javax.media.protocol. *;
    import javax.media.util. *;
    import javax.media.control. *;
    import java.awt.image. *;
    import com.sun.image.codec.jpeg. *;
    import com.sun.media.protocol.vfw.VFWCapture;
    import java.io.*;
    import javax.media.control.FrameGrabbingControl;
    //import com.sun.media.util.JMFSecurity;
    * This is a Java Applet that demonstrates how to create a simple
    * media player with a media event listener. It will play the
    * media clip right away and continuously loop.
    * <!-- Sample HTML
    * <applet code=SimplePlayerApplet width=320 height=300>
    * <param name=file value="sun.avi">
    * </applet>
    * -->
    public class grabframe extends Applet implements ControllerListener,ActionListener
    static int shotCounter = 1;
    Button button;
    // media Player
    Player player = null;
    // component in which video is playing
    Component visualComponent = null;
    // controls gain, position, start, stop
    Component controlComponent = null;
    // displays progress during download
    Component progressBar = null;
    boolean firstTime = true;
    long CachingSize = 0L;
    Panel panel = null;
    int controlPanelHeight = 0;
    int videoWidth = 0;
    int videoHeight = 0;
    * Read the applet file parameter and create the media
    * player.
    public void init()
    setLayout(new BorderLayout());
         setBackground(Color.white);
         panel = new Panel();
         //panel.setLayout( null );
         add(panel,BorderLayout.SOUTH);
         panel.setBounds(0, 0, 320, 240);
    button=new Button("GRAB FRAME");
              panel.add(button);
              button.addActionListener(this);
         // input file name from html param
         String mediaFile = null;
         // URL for our media file
         MediaLocator mrl = null;//MediaLocator describes the location of the media content while
         URL url = null;//URL specify the location of the media
         // Get the media filename info.
         // The applet tag should contain the path to the
         // source media file, relative to the html page.
         if ((mediaFile = getParameter("file")) == null)
         Fatal("Invalid media file parameter");
    //System.out.println("mediafile :"+mediaFile);
         try
         url = new URL(getDocumentBase(), mediaFile);//return a new URL using an existing URL as reference
    //     System.out.println("url :"+url);
                   mediaFile = url.toExternalForm();//return a string representation of the URL
    //     System.out.println("mediafile :"+mediaFile);
              catch (MalformedURLException mue)
         try
         // Create a media locator from the file name
         if ((mrl = new MediaLocator(mediaFile)) == null)
              Fatal("Can't build URL for " + mediaFile);
         // Create an instance of a player for this media
         try
              player = Manager.createPlayer(mrl);
                   catch (NoPlayerException e)
              System.out.println(e);
              Fatal("Could not create player for " + mrl);
    /* catch (CannotRealizeException e)
              System.out.println(e);
              Fatal("Could not create player for " + mrl);
         // Add ourselves as a listener for a player's events
         player.addControllerListener(this);
              catch (MalformedURLException e)
         Fatal("Invalid media file URL!");
              catch (IOException e)
         Fatal("IO exception creating player for " + mrl);
         // This applet assumes that its start() calls
         // player.start(). This causes the player to become
         // realized. Once realized, the applet will get
         // the visual and control panel components and add
         // them to the Applet. These components are not added
         // during init() because they are long operations that
         // would make us appear unresposive to the user.
    }//end of init
    * Start media file playback. This function is called the
    * first time that the Applet runs and every
    * time the user re-enters the page.
    public void start()
         //$ System.out.println("Applet.start() is called");
    // Call start() to prefetch and start the player.
    if (player != null)
         player.start();
    * Stop media file playback and release resource before
    * leaving the page.
    public void stop()
         //$ System.out.println("Applet.stop() is called");
    if (player != null)
    player.stop();
    player.deallocate();
    public void destroy()
         //$ System.out.println("Applet.destroy() is called");
         player.close();
    * This controllerUpdate function must be defined in order to
    * implement a ControllerListener interface. This
    * function will be called whenever there is a media event
    public synchronized void controllerUpdate(ControllerEvent event)
         // If we're getting messages from a dead player,
         // just leave
         if (player == null)
         return;
         // When the player is Realized, get the visual
         // and control components and add them to the Applet
         if (event instanceof RealizeCompleteEvent)
         if (progressBar != null)
              panel.remove(progressBar);
              progressBar = null;
         int width = 320;
         int height = 0;
         if (controlComponent == null)
              if (( controlComponent = player.getControlPanelComponent()) != null)
                        //controlPanelComponent provides the default user interface for controlling the player
              controlPanelHeight = controlComponent.getPreferredSize().height;
              panel.add(controlComponent);
              height += controlPanelHeight;
         if (visualComponent == null)
              if (( visualComponent = player.getVisualComponent())!= null)
                        //visualComponent provides display component(where the visual media is recorded) of the player
              panel.add(visualComponent,BorderLayout.CENTER);
              Dimension videoSize = visualComponent.getPreferredSize();
              videoWidth = videoSize.width;
              videoHeight = videoSize.height;
              width = videoWidth;
              height += videoHeight;
              visualComponent.setBounds(0, 0, videoWidth, videoHeight);
         panel.setBounds(0, 0, width, height);
         if (controlComponent != null)
              controlComponent.setBounds(0, videoHeight,width, controlPanelHeight);
              controlComponent.invalidate();
         } //end of RearizedCompleteEvent
              else if (event instanceof CachingControlEvent)
         if (player.getState() > Controller.Realizing)
              return;
         // Put a progress bar up when downloading starts,
         // take it down when downloading ends.
         CachingControlEvent e = (CachingControlEvent) event;
         CachingControl cc = e.getCachingControl();
         // Add the bar if not already there ...
         if (progressBar == null)
         if ((progressBar = cc.getControlComponent()) != null)
              panel.add(progressBar);
              panel.setSize(progressBar.getPreferredSize());
              validate();
         } //end of CashingControlEvent
                   else if (event instanceof EndOfMediaEvent)
         // We've reached the end of the media; rewind and
         // start over
         player.setMediaTime(new Time(0));
         player.start();
         } //end of EndOfMediaEvent
                   else if (event instanceof ControllerErrorEvent)
         // Tell TypicalPlayerApplet.start() to call it a day
         player = null;
         Fatal(((ControllerErrorEvent)event).getMessage());
    }//end of ControllerErrorEvent
                   else if (event instanceof ControllerClosedEvent)
         panel.removeAll();
         }//end of ControllerClosedEnent
    }//end of controller update
    void Fatal (String s)
         // Applications will make various choices about what
         // to do here. We print a message
         System.err.println("FATAL ERROR: " + s);
         throw new Error(s); // Invoke the uncaught exception
                   // handler System.exit() is another
                   // choice.
    public void actionPerformed(ActionEvent ae)
    Dimension imageSize = null;
    String str=ae.getActionCommand();
    if(str.equals ("GRAB FRAME"))
    Image photo = grabFrameImage();
         if (photo != null)
    MySnapshot snapshot = new MySnapshot(photo, new Dimension(imageSize));
         else
    System.err.println("Errore : Impossibile grabbare il frame");
    repaint();
    * Grabba un frame dalla webcam @restituisce il frame in un buffer
    public Buffer grabFrameBuffer()
    if (player != null)
         FrameGrabbingControl fgc =(FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
    System.out.println(fgc );
         if (fgc != null)
    return (fgc.grabFrame());
         else
    System.err.println("Errore : FrameGrabbingControl non disponibile");
    return (null);
    else
         System.err.println("Errore nel Player");
    return (null);
    * Converte il buffer frame in un'immagine
    public Image grabFrameImage()
    Buffer buffer = grabFrameBuffer();
    if (buffer != null)
    BufferToImage btoi = new BufferToImage((VideoFormat) buffer.getFormat());
    if (btoi != null)
    Image image = btoi.createImage(buffer);
    if (image != null)
    return (image);
              else
    System.err.println("Errore di conversione Buffer - BufferToImage");
    return (null);
         else
    System.err.println("Errore nella creazione di BufferToImage");
    return (null);
         else
    System.out.println("Errore: buffer vuoto");
    return (null);
    class MySnapshot extends JFrame
    protected Image photo = null;
    protected int shotNumber;
         public MySnapshot(Image grabbedFrame, Dimension imageSize)
    super();
    shotNumber = shotCounter++;
    setTitle("Immagine" + shotNumber);
    photo = grabbedFrame;
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    int imageHeight = photo.getWidth(this);
    int imageWidth = photo.getHeight(this);
    setSize(imageSize.width, imageSize.height);
    final FileDialog saveDialog = new FileDialog(this,"Salva immagine", FileDialog.SAVE);
    final JFrame thisCopy = this;
    saveDialog.setFile("Immagine" + shotNumber);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    saveDialog.show();
    String filename = saveDialog.getFile();
    if (filename != null)
    if (saveJPEG(filename))
    JOptionPane.showMessageDialog(thisCopy,"Salvata immagine " + filename);
    setVisible(false);
    dispose();
                             else
    JOptionPane.showMessageDialog(thisCopy,"Errore nel salvataggio di " + filename);
                             else
    setVisible(false);
    dispose();
    setVisible(true);
    public void paint(Graphics g)
    g.drawImage(photo, 0, 0, getWidth(), getHeight(), this);
    public boolean saveJPEG(String filename)
    boolean saved = false;
    BufferedImage bi = new BufferedImage(photo.getWidth(null), photo.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = bi.createGraphics();
    g2.drawImage(photo, null, null);
    FileOutputStream out = null;
    try
    out = new FileOutputStream(filename);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    param.setQuality(1.0f, false);
    encoder.setJPEGEncodeParam(param);
    encoder.encode(bi);
    out.close();
    saved = true;
         catch (Exception ex)
    System.out.println("Errore salvataggio JPEG: "+ ex.getMessage());
    return (saved);
    }//end of class SimplePlayerApplet

    Hmm....
    some of that looks very familiar to me :-)
    http://forum.java.sun.com/thread.jspa?forumID=28&threadID=570463
    1. post your code wrapped in code tags and it'll display it nicely.
    2. post to the Java Media Framework topic,
    I haven't tried JMF within an applet.
    Have you tried getting it working in an application first ?
    That should simplify your debugging to start with.
    I suspect the Player hasn't started yet, or isn't in a realised state.
    regards,
    Owen

Maybe you are looking for

  • How to "clean" my Macbook Pro

    Hi, I'm interested in completely cleaning my Macbook Pro. I've no idea where to start so let me begin by detailing what's going on: Some specs on the machine fist: Processor 2.4GHz Intel Core 2 Duo Memory 4GB 1067 MHz DDR3 Startup Disk Macintosh HD.

  • Error when run "Rollback Run" request...

    Hi, when i run the request "Rollback Run",i get the following error: +++++++++++++++++++++++++++++++++++++++++++++++ HR_6858_HRPROC_INV_PROC_NAME APP-PAY-06858: Invalid process name. Cause: an invalid process name, i.e. not in the following list has

  • Hide background window???

    I'm using Form Builder 6.0.8.16.1 to develop a form, basicly a dialog window that I need to run asyncronuosly using RUN_PRODUCT. My problem is that I'd like to hide the gray background window that apears when I run my dialog using RUN_PRODUCT (If you

  • Simple SQL?

    MYTABLE APPRV_DOC_ID DOC_NUMBER APPROVER REVIEWER Tabular form holds many document numbers with different approvers for example Doc # 100 Approver Alex Reviewer Joe Reviewer Susan Reviewer Don Doc # 200 Approver Joe Reviewer Marty Reviewer Susan Doc

  • Hello, I have a question about videos in general on Firefox. They won't play on Firefox, all I get is a blank white screen or it say "error"?

    What do I do? It started yesterday morning, the videos work on Internet Explorer and Google Chrome but I have all of my bookmarks and my bookmarks tool bar on Firefox. My 8 yr.old son AND my 17 yr.old daughter were on the computer the night before an