passing a vector to an applet

Discussion in 'Java' started by Clive Moore, Oct 11, 2003.

  1. Clive Moore

    Clive Moore Guest

    I need to pass a vector from a jsp page to an applet.

    Is this possible?

    Many Thanks
    Clive


    --
    Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
     
    Clive Moore, Oct 11, 2003
    #1
    1. Advertising

  2. Clive Moore

    Wendy S Guest

    Clive Moore wrote:

    > I need to pass a vector from a jsp page to an applet.
    > Is this possible?


    You'll get better answers if you describe the problem you're trying to
    solve, not the one solution you've picked.

    Is the JSP in question the same one that's sending the <applet> tag (or
    however you do that nowadays) to the browser?

    Without hearing more details, this sounds like a job for a Servlet, not a
    JSP. Use the JSP to send the HTML code that makes the applet happen. Have
    the applet connect back to the server and retrieve the Vector.

    --
    Wendy in Chandler, AZ
     
    Wendy S, Oct 12, 2003
    #2
    1. Advertising

  3. Clive Moore

    Clive Moore Guest

    Wendy,

    to give you a little more info.

    I have a JSP page that performs a serach from a database and sorts the
    restults
    into a vector. I have an applet that is used for displaying the
    results.

    What im trying to do is pass the vector to the applet on startup. Only
    problem being that an applet can only take string parameters which is
    of no use to me.

    I was hoping of a way round this.

    Regards
    Clive




    --
    Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
     
    Clive Moore, Oct 12, 2003
    #3
  4. Clive Moore wrote:
    > I have a JSP page that performs a serach from a database and sorts the
    > restults
    > into a vector. I have an applet that is used for displaying the
    > results.
    >
    > What im trying to do is pass the vector to the applet on startup. Only
    > problem being that an applet can only take string parameters which is
    > of no use to me.


    It will not work like that. JSPs are basically String-oriented.
    And why do you need the applet for? Can't the JSP display the
    results itself.

    If you really need the applet, I'd perform the search in a separate
    Servlet and have the applet make a HTTP request to that Servlet. The
    Servlet can output its result searlized in an ObjectOutputStream, which
    the applet can deserialize.
     
    Michael Borgwardt, Oct 12, 2003
    #4
  5. Clive Moore

    Wendy S Guest

    Clive Moore wrote:

    > What im trying to do is pass the vector to the applet on startup. Only
    > problem being that an applet can only take string parameters which is
    > of no use to me.


    You've got a timing issue... the JSP is executed on the server, it finishes
    and sends the (usually) HTML to the browser, at which time the applet loads
    and starts. The JSP finishes before the applet exists, so it would be
    pretty hard to pass anything anywhere.

    I think the design needs some work, particularly the part about accessing
    the database from a JSP. But that's my MVC and Struts experience talking.

    I'd do the database access in supporting classes, call it from a Servlet and
    forward to a JSP that will cause the applet to load. The Servlet can stick
    the Vector in session scope. Then the applet can connect back to the
    server and request the data.

    Depending on how much data... you could put it in the HTML as string
    parameters, and have the applet read it in, parse it and reconstitute the
    Vector.

    --
    Wendy in Chandler, AZ
     
    Wendy S, Oct 12, 2003
    #5
  6. Clive Moore

    Phil... Guest

    Just convert the vector to strings in the format
    for parameters for the applet.

    "Clive Moore" <> wrote in message
    news:...
    > Wendy,
    >
    > to give you a little more info.
    >
    > I have a JSP page that performs a serach from a database and sorts the
    > restults
    > into a vector. I have an applet that is used for displaying the
    > results.
    >
    > What im trying to do is pass the vector to the applet on startup. Only
    > problem being that an applet can only take string parameters which is
    > of no use to me.
    >
    > I was hoping of a way round this.
    >
    > Regards
    > Clive
    >
    >
    >
    >
    > --
    > Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
     
    Phil..., Oct 13, 2003
    #6
  7. Clive Moore

    jor Guest

    Clive Moore wrote:
    > Wendy,
    >
    > to give you a little more info.
    >
    > I have a JSP page that performs a serach from a database and sorts the
    > restults
    > into a vector. I have an applet that is used for displaying the
    > results.
    >
    > What im trying to do is pass the vector to the applet on startup. Only
    > problem being that an applet can only take string parameters which is
    > of no use to me.
    >
    > I was hoping of a way round this.
    >
    > Regards
    > Clive
    >
    >
    >
    >

    Hi...
    well, you can open a socket if the applet is going to connect to the
    same server which serve the applet. Once the socket is open, you can do
    a writeObject(<vector here>)... (ooops, is Vector serializable? i don't
    remember now 8-| )... anyway... think on writeObjet and socket :cool:))

    but i think a servlet is better than a jsp for that job...

    you have to check if a proxy is enabled, or a firewall...
     
    jor, Oct 13, 2003
    #7
  8. Clive Moore

    Clive Moore Guest

    I understand how to put the vector into the session scope but have no
    idea
    on how to get the applet to access the vector in the session.

    Do you have an example piece of code or can you refer me to a tutorial?

    Thanks for you help
    Regards
    Clive


    > I'd do the database access in supporting classes, call it from a Servlet and
    > forward to a JSP that will cause the applet to load. The Servlet can stick
    > the Vector in session scope. Then the applet can connect back to the
    > server and request the data.
    >





    --
    Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
     
    Clive Moore, Oct 13, 2003
    #8
  9. Clive Moore

    Wendy S Guest

    "Clive Moore" <> wrote in message
    news:...
    > I understand how to put the vector into the session scope but have no
    > idea
    > on how to get the applet to access the vector in the session.
    > Do you have an example piece of code or can you refer me to a tutorial?


    I happen to think applets are evil so I have *no* experience with this, but
    I know that you can send serialized objects over HTTP. (Is Vector
    serializable? Any reason you're not using ArrayList?) I see it connecting
    to a separate Servlet whose job it is to pick an object out of the session
    and write it out over HTTP.

    This might apply...
    http://www.javaworld.com/javaworld/javatips/jw-javatip103.html

    --
    Wendy in Chandler, AZ
     
    Wendy S, Oct 14, 2003
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pmatos
    Replies:
    6
    Views:
    24,040
  2. Replies:
    8
    Views:
    1,988
    Csaba
    Feb 18, 2006
  3. Replies:
    2
    Views:
    508
    David Harmon
    Feb 9, 2007
  4. Javier
    Replies:
    2
    Views:
    604
    James Kanze
    Sep 4, 2007
  5. Rushikesh Joshi
    Replies:
    0
    Views:
    387
    Rushikesh Joshi
    Jul 10, 2004
Loading...

Share This Page