How to POST an object in an Applet to a JSP server?

I'm trying to realize such a functionality: when the 'Submit' button of a form is clicked, the form fields as well as a 'byte[]' object in an Applet in the page are POSTed to the JSP server. How to implement this?
PS I hope I'm posting in the right forum.

You could do something like this. Probably you want to make it more generic to be able to add an arbitrary number of fields, but I hope you get an idea.
private void postData() {
       URL url = new URL(/* your url here */);
       URLConnection connection = url.openConnection();
       String boundary = "----------" + Long.toHexString(System.currentTimeMillis());
       connection.setRequestProperty("method", "POST");
       connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
       String name1;        // the name of the first field
       String value1;       // the value of the first field
       String name2;        // the name of the second field
       byte[] value2array; // the value of the second field or some object converted to a byte array
       String output =
               "--" + boundary + "\r\n"
               + "Content-Disposition: form-data; name=\"" + name1 + "\"\r\n"
               + "Content-Type: text/plain\r\n"
               + "Content-Transfer-Encoding: quoted-printable\r\n\r\n"
               + value1 + "\r\n"
               + "--" + boundary + "\r\n"
               + "Content-Disposition: form-data; name=\""+ name2 +"\"\r\n"
               + "Content-Type: image/png\r\n"
               + "Content-Transfer-Encoding: base64\r\n\r\n"
               + new String(value2array) + "\r\n"
               + "--" + boundary + "--\r\n";
       connection.setDoOutput(true);
       connection.getOutputStream().write(output.getBytes());
       connection.connect();
}

Similar Messages

  • How to post a Object in HttpService?

    Such as:
    <mx:HTTPService id="HSDemo" method="POST"
    showBusyCursor="true" url="goalInsert.action">
    <mx:request>
    <book.title>{names.text}</book.title>
    </mx:request>
    </mx:HTTPService>
    RESULT: "{names.text}" is undefined.
    WHY?

    First, you are doing a few things I don't undertand.
    The url property, for instance does not look valid. Can you
    type that in a browser address and get anything back?
    The child tags of mx:request are supposed to create
    properties on the request object. I don't think "book.title" is
    valid. Does that compile ok?
    How are you invoking the send?
    How are you handling the result?
    Assuming "names" is the id of a TextInput or TextArea, I
    would think your code should look like this:
    <mx:HTTPService id="HSDemo" method="POST"
    showBusyCursor="true"
    url="
    http://myWebServer/myApp/myJSP.jsp">
    <mx:request>
    <action>insert</action>
    <booktitle>{names.text}</booktitle>
    </mx:request>
    </mx:HTTPService>
    Also, to do this in AS:
    var oRequest
    bject = {title:names.text,action:"insert"};
    HSDemo.send(oRequest);
    You do not need the mx:request tags this way, and you can
    more easily debug to make sure names.text has a value.
    Tracy

  • How to transfer the http request from applet to servlet/jsp

    I use the JTree component to create a navigation of a website,but i don't
    know how to connect the tree's nodes with the jsp/servlet.
    I mean how to transfer the http request from the applet to a jsp.
    I use the "<frameset>" mark which will divide the web browse into 2 blocks.
    The left side is Applet,and the right side is the linked jsp page.
    what I say is as the weblogic console layout.
    who can help me!!!
    Thank You!

    I use the JTree component to create a navigation of a website,but i don't
    know how to connect the tree's nodes with the jsp/servlet.
    I mean how to transfer the http request from the applet to a jsp.
    I use the "<frameset>" mark which will divide the web browse into 2 blocks.
    The left side is Applet,and the right side is the linked jsp page.
    what I say is as the weblogic console layout.
    who can help me!!!
    Thank You!

  • How to create an object alive all the time on a server side

    Hi,
    I work on an Intranet with J2EE technologies. I need an object to do several tasks in background on the server side. Like start scheduled processes on a database and files, stocked on the server. What is the way to do this. I thought to use the JNDI by declaring the object in the Deployement Descriptor, and to manage a timer within.
    I don't know if this works.
    Anyway, my question is how to create an object on the server that is ALIVE ALL THE TIME and visible by the other objects running in the same VM.
    Thank's.

    This may not be the correct design, but I had success doing the following:
    1. Create an Stateless EJB that does a task, i.e. update a database table.
    2. Create a subclass of java.util.TimerTask to call the EJB methods.
    3. Kick off the TimerTask from a servlet.init method.
    Seems to work pretty well to do scheduled tasks, such as refreshing lookup tables. I would imagine the same could be done with an MBean, but I haven't had time to fully understand JMX yet. (It's on the list).
    As for event driven procedures, that can be done through a servlet interface.
    You may also wish to review a scheduler here: http://www.part.net/quartz.html. Note, I have NOT even looked at it yet, so I have no clue if it's any good. But, it is on my list of tools to evaluate (that's a long list) someday when my head's above water. Have a look, and caveat emptor.
    Hope this helps,
    Perry Tew

  • How to Use Sequence Object Inside User-defined Function In SQL Server

    I'm trying to call sequence object inside SQL Server user-defined function. I used 
    Next Value for dbo.mySequence  to call the next value for my sequence created. But I'm getting an error like below.
    "NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, or derived tables."
    Is there any standard way to call sequence inside a function?
    I would really appreciate your response.
    Thanks!

    The NEXT
    VALUE FOR function cannot be used for User Defined function. It's one of the limitation.
    https://msdn.microsoft.com/en-us/library/ff878370.aspx
    What are you trying to do? Can you give us an example and required output?
    --Prashanth

  • How to set  an object in request scope in  a jsp uysing  jstl

    I usally use scriptlet in jsp to set an object in request is
    there a way to do this using jstl
    instead of this
    <%request.setAttribute("test",myObject);%> I want to use tag ?

    The <c:set> tag should be useful...
    Of course if you can access it as a JSTL variable it IS already an attribute in scope.

  • Passing objects to a applet.

    hi there,
    i have a jsp and a applet. i need to pass an object from my jsp to the applet and the applet will present the results.
    how can i do it?? how do i pass objects to the applet??
    thanks

    you typically pass strings as applet parameters in the page.
    otherwise, you have your applet connect back to the server with a socket or URLConnection to a servlet, which can send serialized objects if that's what you need, or other data.

  • How to passing object to the applet?

    Dear All,
    My project is needed to read the xml file (include the form content) and then parse the xml file to create the related object, so using the applet to display this dynamic form.
    Due to cannot directly open the file object and the applet, the following is my idea:
    1. ) In the servlet, first to new the fileinputstream object , then pass the object into the applet. But this idea is not allowed.
    Only String value can use the param to to pass the parameter value to the applet using <param name = \"cis_auditID\" value = \""+inputsource+"\">.
    2. ) Firstly , read the file and then create specific object before call applet class. I know some people said that using the URLConnection, but i don't know for this. Can only one give more detail description about that.
    So how can i pass the fileinputstream or the own created object into the applet?
    Urgent! Please help!

    Where is the xml file located??
    If it's on the same server that serves the applet or if it's dynamically generated
    by making a http request to a servlet you should use URL and URLConnection.
    URL u = new URL(this.getCodeBase(),"../relativeDir/xmlFile.xml");
    URLConnection uc = u.openConnection();
    InputStream = uc.getInputStream();
    // read the rest of the struff.
    You might want to take a look at this example if you want to send (POST data) to
    the server when you make a http request to a servlet:
    http://forums.java.sun.com/thread.jspa?threadID=645830&tstart=0
    3rd post

  • Best IDE and how-to create HTML for a swing Applet

    Can you help me out? I've been using, and teaching with the old Symantec VisualCafe product from long, long, ago. It still works fine & I can even use it to build JFC/Swing Applets etc. But a few things have occurred. For one, a way back, Symantec sold VisualCafe to WEBGAIN - who now has gone out of business and sold it to a company called TOGETHERSOFT - who doesn't support it any longer.
    This isn't really a big deal to me, because I can still build and deploy applets that are pre-swing easily enough. (as can my students)
    HOWEVER... I'd like to be running with the LATEST Java (I think it's 1.4.01) and I'd LIKE to use whatever is the best development environment I can use - especially one I can recommend to my students. Do you know what that should be?
    What's more, I'd still like to take some JFC/Swing created applets (even if compiled with the older VisualCafe IDE) and generate the HTML to allow 1.4 enabled browsers to run them (this is the case for the schools versions of Explorer and Netscape). Now, the HTML I have INSTALLED for the students used the HTML converter - back in 1.2 to produce the HTML at the bottom of this. This code no longer works now with current browsers. Do you know HOW one makes a jfc/swing compiled applet run on the latest browsers?
    Any help or direction you can give would be appreciated.
    thanks,
    Bobby Berns
    [email protected]
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 756 HEIGHT = 396 codebase="http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0">
    <PARAM NAME = CODE VALUE = "lottery.class" >
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
    <COMMENT>
    <EMBED type="application/x-java-applet;version=1.2" java_CODE = "lottery.class" WIDTH = 756 HEIGHT = 396 pluginspage="http://java.sun.com/products/plugin/1.2/plugin-install.html"><NOEMBED></COMMENT>
    </NOEMBED></EMBED>
    </OBJECT>
    <!--
    <APPLET CODE = "lottery.class" WIDTH = 756 HEIGHT = 396 >
    </APPLET>
    -->
    <!--"END_CONVERTED_APPLET"-->

    Bobby,
    It's been a while since I've used the HTML Converter, but if I had to guess I'd say you need a newer version than what you have. Also, doesn't the converter allow you to choose which JDK you want to use (in which case you could select 1.4)? Again it's been a while so bear with me. Another option would be to put all the Swing classes into a .jar file (typically called swingall.jar) on your server and include that file as an attribute in your applet tag like this:
    <APPLET CODE="yourApplet.class" ARCHIVE="swingall.jar">
    This way you don't have to use the Java Plug-in, however the initial download time of the .jar file can be significant.
    As for an IDE, I've always been happy using a text editor like UltraEdit. However, I've heard good things about Forte, and hey, it's free!
    Regarding Christina's post, that solution will only work if the Applet does not use Swing components (and Bobby specifically said it does). By using the <OBJECT> and <EMBED> tags, rather than the <APPLET> tag, you force the browser to use the Java Plug-in (rather than the browser's default JVM).
    Hope that helps,
    - Sheepy

  • HOW TO: Post a SQL statement tuning request - template posting

    This post is not a question, but similar to Rob van Wijk's "When your query takes too long ..." post should help to improve the quality of the requests for SQL statement tuning here on OTN.
    On the OTN forum very often tuning requests about single SQL statements are posted, but the information provided is rather limited, and therefore it's not that simple to provide a meaningful advice. Instead of writing the same requests for additional information over and over again I thought I put together a post that describes how a "useful" post for such a request should look like and what information it should cover.
    I've also prepared very detailed step-by-step instructions how to obtain that information on my blog, which can be used to easily gather the required information. It also covers again the details how to post the information properly here, in particular how to use the \ tag to preserve formatting and get a fixed font output:
    http://oracle-randolf.blogspot.com/2009/02/basic-sql-statement-performance.html
    So again: This post here describes how a "useful" post should look like and what information it ideally covers. The blog post explains in detail how to obtain that information.
    In the future, rather than requesting the same additional information and explaining how to obtain it, I'll simply refer to this HOW TO post and the corresponding blog post which describes in detail how to get that information.
    *Very important:*
    Use the \ tag to enclose any output that should have its formatting preserved as shown below.
    So if you want to use fixed font formatting that preserves the spaces etc., do the following:
    \   This preserves formatting
    \And it will look like this:
       This preserves formatting
       . . .Your post should cover the following information:
    1. The SQL and a short description of its purpose
    2. The version of your database with 4-digits (e.g. 10.2.0.4)
    3. Optimizer related parameters
    4. The TIMING and AUTOTRACE output
    5. The EXPLAIN PLAN output
    6. The TKPROF output snippet that corresponds to your statement
    7. If you're on 10g or later, the DBMS_XPLAN.DISPLAY_CURSOR output
    The above mentioned blog post describes in detail how to obtain that information.
    Your post should have a meaningful subject, e.g. "SQL statement tuning request", and the message body should look similar to the following:
    *-- Start of template body --*
    The following SQL statement has been identified to perform poorly. It currently takes up to 10 seconds to execute, but it's supposed to take a second at most.
    This is the statement:
    select
    from
             t_demo
    where
             type = 'VIEW'
    order by
             id;It should return data from a table in a specific order.
    The version of the database is 11.1.0.7.
    These are the parameters relevant to the optimizer:
    SQL>
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_capture_sql_plan_baselines boolean     FALSE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      11.1.0.7
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    optimizer_use_invisible_indexes      boolean     FALSE
    optimizer_use_pending_statistics     boolean     FALSE
    optimizer_use_sql_plan_baselines     boolean     TRUE
    SQL>
    SQL> show parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     8
    SQL>
    SQL> show parameter db_block_size
    NAME                                 TYPE        VALUE
    db_block_size                        integer     8192
    SQL>
    SQL> show parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACT
    SQL>
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL>
    SQL> select
      2             sname
      3           , pname
      4           , pval1
      5           , pval2
      6  from
      7           sys.aux_stats$;
    SNAME                PNAME                     PVAL1 PVAL2
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          01-30-2009 16:25
    SYSSTATS_INFO        DSTOP                           01-30-2009 16:25
    SYSSTATS_INFO        FLAGS                         0
    SYSSTATS_MAIN        CPUSPEEDNW              494,397
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    13 rows selected.Here is the output of EXPLAIN PLAN:
    SQL> explain plan for
      2  -- put your statement here
      3  select
      4             *
      5  from
      6             t_demo
      7  where
      8             type = 'VIEW'
      9  order by
    10             id;
    Explained.
    Elapsed: 00:00:00.01
    SQL>
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    60 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |     1 |    60 |     0   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    14 rows selected.Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
    SQL> rem Set the ARRAYSIZE according to your application
    SQL> set autotrace traceonly arraysize 100
    SQL> select
      2             *
      3  from
      4             t_demo
      5  where
      6             type = 'VIEW'
      7  order by
      8             id;
    149938 rows selected.
    Elapsed: 00:00:02.21
    Execution Plan
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    60 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |     1 |    60 |     0   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    Statistics
              0  recursive calls
              0  db block gets
         149101  consistent gets
            800  physical reads
            196  redo size
        1077830  bytes sent via SQL*Net to client
          16905  bytes received via SQL*Net from client
           1501  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
         149938  rows processed
    SQL>
    SQL> disconnect
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing optionsThe TKPROF output for this statement looks like the following:
    TKPROF: Release 11.1.0.7.0 - Production on Mo Feb 23 10:23:08 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Trace file: orcl11_ora_3376_mytrace1.trc
    Sort options: default
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    select
    from
             t_demo
    where
             type = 'VIEW'
    order by
             id
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch     1501      0.53       1.36        800     149101          0      149938
    total     1503      0.53       1.36        800     149101          0      149938
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 88 
    Rows     Row Source Operation
    149938  TABLE ACCESS BY INDEX ROWID T_DEMO (cr=149101 pr=800 pw=0 time=60042 us cost=0 size=60 card=1)
    149938   INDEX RANGE SCAN IDX_DEMO (cr=1881 pr=1 pw=0 time=0 us cost=0 size=0 card=1)(object id 74895)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                    1501        0.00          0.00
      db file sequential read                       800        0.05          0.80
      SQL*Net message from client                  1501        0.00          0.69
    ********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
    SQL> -- put your statement here
    SQL> -- use the GATHER_PLAN_STATISTICS hint
    SQL> -- if you're not using STATISTICS_LEVEL = ALL
    SQL> select /*+ gather_plan_statistics */
      2  *
      3  from
      4  t_demo
      5  where
      6  type = 'VIEW'
      7  order by
      8  id;
    149938 rows selected.
    Elapsed: 00:00:02.21
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  d4k5acu783vu8, child number 0
    select   /*+ gather_plan_statistics */          * from          t_demo
    where          type = 'VIEW' order by          id
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT            |          |      1 |        |    149K|00:00:00.02 |     149K|   1183 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |      1 |      1 |    149K|00:00:00.02 |     149K|   1183 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |      1 |      1 |    149K|00:00:00.02 |    1880 |    383 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    20 rows selected.I'm looking forward for suggestions how to improve the performance of this statement.
    *-- End of template body --*
    I'm sure that if you follow these instructions and obtain the information described, post them using a proper formatting (don't forget about the \ tag) you'll receive meaningful advice very soon.
    So, just to make sure you didn't miss this point:Use proper formatting!
    If you think I missed something important in this sample post let me know so that I can improve it.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Alex Nuijten wrote:
    ...you missed the proper formatting of the Autotrace section ;-)Alex,
    can't reproduce, does it still look unformatted? Or are you simply kidding? :-)
    Randolf
    PS: Just noticed that it actually sometimes doesn't show the proper formatting although the code tags are there. Changing to the \ tag helped in this case, but it seems to be odd.
    Edited by: Randolf Geist on Feb 23, 2009 11:28 AM
    Odd behaviour of forum software                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I create Object Tag which supports Sun and MS JVM both.

    Hi,
    I have created object tag as shown below
    <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    name = "TestApplet" height="0" width="0" >
    <param name="code" value="com.apps.TestApplet.class" />
    <param name="codebase" value="codes" />
    <param name="archive" value="TestApplet.jar" />
    </object>
    The above tag is working fine with the below JVM combinations in Windows XP.
    1) Only Sun JVM
    2) Only MS JVM
    3) Sun JVM & MS JVM
    But these conditions are not working with Windows 2000.
    How we can create object tag which will support for these two opertating systems?

    I am not able to understand the problem. From my understanding, you have an applet which you are trying to display in a browser using <object> tag. If that is the correct then all it matters is the browser and the JRE�
    For example the below code when put in a JSP or a HTML, will use JRE 1.6.0_01 that is available on the client machine. If that is not available on the client machine then it will try and download automatically in IE.
    This below code is for IE� if you are using Mozilla Firefox then you need to change the �classid� attribute to �java: com.foo.bar.ui.MyClass�
    <OBJECT ID="Gantt" classid = "clsid:CAFEEFAC-0016-0000-0001-ABCDEFFEDCBA"
                  codebase = "http://java.sun.com/update/1.6.0/jinstall-6u1-windows-i586.cab"
                  WIDTH = "980" HEIGHT = "495" ALIGN = "baseline">
                   <PARAM NAME="cache_option" VALUE="Plugin">
                  <PARAM NAME ="CODE" VALUE = "com.foo.bar.ui.MyClass" >
                  <PARAM NAME="MAYSCRIPT" VALUE="true">
                  <PARAM NAME ="cache_archive" VALUE = "Myjar.jar /" >
                  <PARAM NAME = "type" VALUE = "application/x-java-applet;jpi-version=1.6.0">
                  <PARAM NAME = "scriptable" VALUE = "false">
                  <strong>
                     This browser does not have a Java 1.6.0_01 Plug-in.
                     <br />
                     <a href="http://java.sun.com/update/1.6.0/jinstall-6u1-windows-i586.cab">
                       Get the latest Java Plug-in here.
                     </a>
              </strong>
            </OBJECT>

  • How to create an object within the same class???

    hi im just a newbie
    i v been always creating an object from the main class..
    but how to create an object inside the same class??
    i got main and students class
    the main got an array
    Students[] stu = new Students[]
    and i got
    stu[i] = new Students(id,name);
    i++;
    but i wanna do these things inside the Students class..
    i tried ..but i got errors.....
    how to do this
    .

    javaexpert, :)
    I really have no idea what you are trying to do since you say you've always been creating an object from the main class, yet you always want to create an object inside the same class.
    I'll assume that you have an object in the main class that you are trying to access from the Students class.
    If you are trying to access objects that are contained within the main class FROM the Students class, then know that there are two ways of doing so, one being static, and the other dynamic (look up definitions if unclear):
    1.) make the objects in the main class both static and public and access the the objects using a convention similiar to: Main.object; It's important to note that Main is the name of your main class, and object is a static object. There are better ways of doing this by using gettter/setter methods, but I'll omit that tutorial.
    2.) Create a new instance of the main class and access the objects using a similiar fashion: Main myInstance = new Main(); myInstance.myObject;
    You should really use getter and setter methods but I'll omit the code. In terms of which approach is better, step one is by far.
    I don't mean to be condecending, but you should really brush up on your programming skills before posting to this forum. This is a fundamenetal concept that you will encounter time and time again.

  • How to use C-Structure in java applets

    hi alls,
    I want to use a struct model (struct in C++) in java applets. i know class is used in java applications. but, how can i convert in java applets?
    class renk
    int r;
    int gr;
    int b;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.Event;
    import java.applet.Applet;
    public class benek extends Applet
    final int n=10;
    int x[] = new int[n];
    int y[] = new int[n];
    int count = 0;
    renk clr[] = new renk[n];
    public void init()
    setBackground(Color.black);
    public boolean mouseDown(Event yordam, int xyer, int yyer)
    if (count<n)
    System.out.println("...");
    ekle(xyer,yyer);
    else System.out.println("Kapasite Doldu...");
    return true;
    void ekle(int xyer, int yyer)
    int r1 = (int)Math.floor(Math.random()*256);
    int gr1 = (int)Math.floor(Math.random()*256);
    int b1 = (int)Math.floor(Math.random()*256);
    clr[count].r = r1;
    clr[count].gr = gr1;
    clr[count].b = b1;
    x[count]=xyer;
    y[count]=yyer;
    count++;
    repaint();
    public void paint(Graphics g)
    it gives error message... how can � use struct model in java applets???
    if you help me i will be greatfull....

    � use import but it doesn't work.
    i add: import renk; or import class renk;
    how will � add import I assumed based on your initial post that the renk and benek classes were in the same file. Apparently you're saying they are not. So for another thing, make your renk class "public class renk", and add the "public" keyword to the 3 members of that class. Then if your code still doesn't see the "renk" class, it would just be that you don't have the directory that contains the compiled "renk.class" in your classpath.

  • How to create good object model?

    Does anybody know how to create good object model?
    Again and again I have to create different object models in various projects. I have to solve a lot of problems.
    - Define all entities
    - Create objects for it
    - Define relations (ususlly i use SQL Databases)
    - Define methods to load/edit/save/delete entities.
    - Define methods to search and featch set of entities
    - Define events for entities (fired when it change)
    - the biggest problem is the events for collections. If i got the collection of entities for filter [FirstName = 'Sam'] i want to recieve event NewEntityAdded(), when new entity with FirstName='Sam' is created. But i want not to recieve event when that new entity's FirstName = 'Jack'.
    Do anybody know good book or set of articles for such a questions?

    Hi Facedown12,
    Does the issue resolved based on the Tatynan's suggestion? If the issue persists, please post the detail information about
    your issue, so that we can make further analysis.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to persistent static object

    JDO always assigns a StateManager to a PersistenceCapable object when
    creating instance. If an object is static, it'll keep its StateManager for
    ever after instantiation. So If I excute the following code repeadly, kodo
    will complain that persistence manager has been closed.
    1) Get PersistenceManager
    2) Begin transaction
    3) Get object from datastore. If not exist, create a new object. This
    object is a static.
    4) Commit transaction
    5) pm.close
    For the first time, kodo will assign a new StateManager to this static
    object. But for the second time, exception, "persistence manager has been
    closed", will arise when excuting some of object's methods. Because each
    StateManager object owns a PersistenceManager object. If this pm is
    closed, according StateManager object is also useless.
    After enhancing, kodo will change some getter/setter methods to
    according jdo getter/setter ones. These methods may invoke
    startManager.isLoaded(), which invokes pm.isActive(). Unfortunately, pm
    has been closed.
    Any other tricky methods to persistent static object ?
    Thanks !

    Dear Marc,
    Thanks for your kind help. It's an effective advice to prevent
    persistent object from being static.
    However, what if the object to be persistent is an enumeration type
    constant ? For example :
    public class MyEnumType
    private String name = null;
    private int value = 0;
    protected MyEnumType( String name, int value )
    this.name = name;
    this.value = value;
    public static final TYPE_1 = new MyEnumType( "type 1", 1 );
    public class EnumTypeUseClass
    private MyEnumType type = null;
    public void setType(..) {..}
    public MyEnumType getType() {..}
    public class TestClass
    public void f()
    PersistenceManager pm = null;
    try
    // Obtain pm
    pm = ...;
    pm.currentTransaction().begin();
    EnumTypeUseClass use = new EnumTypeUseClass();
    // Obtain myenumtype object from datastore
    MyEnumType type = getJdoObject( pm, MyEnumType.class, "value ==" +
    MyEnumType.TYPE_1.getValue() );
    // Following line will cause "PersistenceManager has been closed"
    exception
    use.setType( type );
    pm.makePersistent( use );
    pm.currentTransaction().commit();
    catch( .. )
    finally
    pm.close();
    public static void main( String args[] )
    for( int i = 0; i < 10; i ++ )
    f();
    Actually, exception is caused by MyEnumType.TYPE_1.getValue() because
    this object's pm has been closed in the first loop time.
    Now I solved this problem by not persistent MyEnumType objects, and
    change type field in EnumTypeUseClass from MyEnumType to int.
    But I still wonder how to persistent static objects.
    Maybe your first advice is feasible, but I think it will make your
    program tangly. Do you think so ? :)
    Marc Prud'hommeaux wrote:
    Liang-
    You are correct that a persistent instance must be associated with a
    PersistenceManager. You could always just leave the PersistenceManager
    open (if using optimistic transaction, Kodo won't tie up database
    resources in this case). Another option is to not have the singleston
    instance be a static variable, but have it be obtained via a factory
    method that takes a PersistenceManager argument.
    If this doesn't help, perhaps you could help clarify the situation by
    posting some code that shows that you would like to do?
    In article <[email protected]>, Liang Zhilong wrote:
    JDO always assigns a StateManager to a PersistenceCapable object when
    creating instance. If an object is static, it'll keep its StateManager for
    ever after instantiation. So If I excute the following code repeadly, kodo
    will complain that persistence manager has been closed.
    1) Get PersistenceManager
    2) Begin transaction
    3) Get object from datastore. If not exist, create a new object. This
    object is a static.
    4) Commit transaction
    5) pm.close
    For the first time, kodo will assign a new StateManager to this static
    object. But for the second time, exception, "persistence manager has been
    closed", will arise when excuting some of object's methods. Because each
    StateManager object owns a PersistenceManager object. If this pm is
    closed, according StateManager object is also useless.
    After enhancing, kodo will change some getter/setter methods to
    according jdo getter/setter ones. These methods may invoke
    startManager.isLoaded(), which invokes pm.isActive(). Unfortunately, pm
    has been closed.
    Any other tricky methods to persistent static object ?
    Thanks !
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

Maybe you are looking for

  • SMB no longer working in 10.4.8???

    I was happily connecting to both my daughters iMac and my husbands Windows PC using SMB.....then it stopped working?! Now obviously something must have happened to change this and I've been thinking what it could be. Well nothing had changed on eithe

  • MacBook - Black & white image on TV

    Please can somebody help with connecting my MacBook to a Sony trinitron TV I have a new MacBook and I'm using the following set up to connect to a 5 year old Sony TV - Apple mini-DVI to video converter into S-video lead connected to S-video to SCART

  • Problem using text boxes as the "image" to drag and drop over audio file

    I have been adding audio files to my page in iWeb (previous version, not '08), but I am having a problem giving them titles. When you first drag a file from iTunes into iWeb, it provides a space for you to drag and drop a picture. The online iWeb gui

  • QUICKEST way from FCP to DVD

    I need to know the quickest way to get a movie in FCP onto a DVD. What I normally do is convert the file to Quicktime, and then put that into I-DVD. The problem right now is that just converting the movie to Quicktime is taking 6 hours. Is there anot

  • RECIPE SYSTEM

    I am trying to implement a recipe system, I would like the user to choose from a listbox the recipe that they want, then use the index returned from that to select the values from a 2D array (128 recipes, 7 parameters). First off would this be the be