Sending a lot of info the a jsp page

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending a lot of info the a jsp page

Dola Woolfe
Hi,

This question will reveal how little I know about
networking or http or something else.

Basically I wrote an applet that sends data to a
servlet. I do it by forming a url with a query string
(GET). But this doesn't work when there's too much
data.

What are my options?
Is it possible to use POST?
Or, better yet, is it possible to send a java object
by creating a socket connection with the servlet?

Very many thanks in advance!

Dola

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending a lot of info the a jsp page

Leon Rosenberg-3
On 1/20/06, Dola Woolfe <[hidden email]> wrote:

> Hi,
>
> This question will reveal how little I know about
> networking or http or something else.
>
> Basically I wrote an applet that sends data to a
> servlet. I do it by forming a url with a query string
> (GET). But this doesn't work when there's too much
> data.
>
> What are my options?
> Is it possible to use POST?
> Or, better yet, is it possible to send a java object
> by creating a socket connection with the servlet?

Creating a socket is the easiest way for you, the only restriction is,
that you can only connect to the server the applet came from (unless
its signed) and have to bypass proxies etc. by yourself. And you need
of course something listening to the socket on the other end...

regards
Leon

>
> Very many thanks in advance!
>
> Dola
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending a lot of info the a jsp page

Glen Mazza-4
In reply to this post by Dola Woolfe
Dola Woolfe wrote:

> Hi,
>
> This question will reveal how little I know about
> networking or http or something else.
>
> Basically I wrote an applet that sends data to a
> servlet. I do it by forming a url with a query string
> (GET). But this doesn't work when there's too much
> data.
>
> What are my options?
> Is it possible to use POST?

This article: http://www.javaworld.com/javaworld/javatips/jw-javatip34.html
gives a sample applet that uses HTTP POST.

Glen

> Or, better yet, is it possible to send a java object
> by creating a socket connection with the servlet?
>
> Very many thanks in advance!
>
> Dola
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending a lot of info the a jsp page

Dola Woolfe
In reply to this post by Leon Rosenberg-3


--- Leon Rosenberg <[hidden email]>
wrote:

> On 1/20/06, Dola Woolfe <[hidden email]> wrote:
> > Hi,
> >
> > This question will reveal how little I know about
> > networking or http or something else.
> >
> > Basically I wrote an applet that sends data to a
> > servlet. I do it by forming a url with a query
> string
> > (GET). But this doesn't work when there's too much
> > data.
> >
> > What are my options?
> > Is it possible to use POST?
> > Or, better yet, is it possible to send a java
> object
> > by creating a socket connection with the servlet?
>
> Creating a socket is the easiest way for you, the
> only restriction is,
> that you can only connect to the server the applet
> came from (unless
> its signed) and have to bypass proxies etc. by
> yourself. And you need
> of course something listening to the socket on the
> other end...
>
> regards
> Leon
>

Can you point to some documentation or examples?

Will I be able to do this in the context of a servlet
(or a jsp page) or will I have to write an altogether
new beast running alongside tomcat that is listening
to a socket on some other port?

Thanks!

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending a lot of info the a jsp page

TonyCoco
In reply to this post by Dola Woolfe
Hi Dola
  yes you can use  POST for an unlimited amount of data but of course you'll need to set your http headers correctly, specifically the Content-Length header.

 -------------- Original message ----------------------
From: Dola Woolfe <[hidden email]>

> Hi,
>
> This question will reveal how little I know about
> networking or http or something else.
>
> Basically I wrote an applet that sends data to a
> servlet. I do it by forming a url with a query string
> (GET). But this doesn't work when there's too much
> data.
>
> What are my options?
> Is it possible to use POST?
> Or, better yet, is it possible to send a java object
> by creating a socket connection with the servlet?
>
> Very many thanks in advance!
>
> Dola
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending a lot of info the a jsp page

Bill Barker-2
In reply to this post by Dola Woolfe

"Dola Woolfe" <[hidden email]> wrote in message
news:[hidden email]...

> Hi,
>
> This question will reveal how little I know about
> networking or http or something else.
>
> Basically I wrote an applet that sends data to a
> servlet. I do it by forming a url with a query string
> (GET). But this doesn't work when there's too much
> data.
>
> What are my options?
> Is it possible to use POST?
> Or, better yet, is it possible to send a java object
> by creating a socket connection with the servlet?
>

Actually, combining these two is often easiest (of course, your java Object
must implement Serializable for this to work).  Something like (Applet
code):

     URL servlet = new URL(getDocumentBase(), "/path/to/my/servlet");
     HttpURLConnection conn = (HttpURLConnection)servlet.openConnection();
     conn.setDoInput(true);
     conn.setDoOutput(true);
     conn.setRequestMethod("POST");
     conn.setHeaderField("Content-Type", "application/x-java");
     ObjectOutputStream out = new
ObjectOutputStream(conn.getOutputStream());
     out.writeObject(myObject);
     int status = conn.getResponseCode();
     if(isOK(status)) {
         InputStream in = conn.getInputStream();
        // Handle response here.
     }


> Very many thanks in advance!
>
> Dola
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending a lot of info the a jsp page

Dola Woolfe


--- Bill Barker <[hidden email]> wrote:

>
> "Dola Woolfe" <[hidden email]> wrote in message
>
news:[hidden email]...

> > Hi,
> >
> > This question will reveal how little I know about
> > networking or http or something else.
> >
> > Basically I wrote an applet that sends data to a
> > servlet. I do it by forming a url with a query
> string
> > (GET). But this doesn't work when there's too much
> > data.
> >
> > What are my options?
> > Is it possible to use POST?
> > Or, better yet, is it possible to send a java
> object
> > by creating a socket connection with the servlet?
> >
>
> Actually, combining these two is often easiest (of
> course, your java Object
> must implement Serializable for this to work).
> Something like (Applet
> code):
>
>      URL servlet = new URL(getDocumentBase(),
> "/path/to/my/servlet");
>      HttpURLConnection conn =
> (HttpURLConnection)servlet.openConnection();
>      conn.setDoInput(true);
>      conn.setDoOutput(true);
>      conn.setRequestMethod("POST");
>      conn.setHeaderField("Content-Type",
> "application/x-java");
>      ObjectOutputStream out = new
> ObjectOutputStream(conn.getOutputStream());
>      out.writeObject(myObject);
>      int status = conn.getResponseCode();
>      if(isOK(status)) {
>          InputStream in = conn.getInputStream();
>         // Handle response here.
>      }
>
That's fantastic! And what does the jsp side look
like? I only know how to get data through
getParameter...


Thanks!

>
> > Very many thanks in advance!
> >
> > Dola
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com 
>
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [hidden email]
> For additional commands, e-mail:
> [hidden email]
>
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending a lot of info the a jsp page

Bill Barker-2

"Dola Woolfe" <[hidden email]> wrote in message
news:[hidden email]...

>
>
> --- Bill Barker <[hidden email]> wrote:
>
>>
>> "Dola Woolfe" <[hidden email]> wrote in message
>>
> news:[hidden email]...
>> > Hi,
>> >
>> > This question will reveal how little I know about
>> > networking or http or something else.
>> >
>> > Basically I wrote an applet that sends data to a
>> > servlet. I do it by forming a url with a query
>> string
>> > (GET). But this doesn't work when there's too much
>> > data.
>> >
>> > What are my options?
>> > Is it possible to use POST?
>> > Or, better yet, is it possible to send a java
>> object
>> > by creating a socket connection with the servlet?
>> >
>>
>> Actually, combining these two is often easiest (of
>> course, your java Object
>> must implement Serializable for this to work).
>> Something like (Applet
>> code):
>>
>>      URL servlet = new URL(getDocumentBase(),
>> "/path/to/my/servlet");
>>      HttpURLConnection conn =
>> (HttpURLConnection)servlet.openConnection();
>>      conn.setDoInput(true);
>>      conn.setDoOutput(true);
>>      conn.setRequestMethod("POST");
>>      conn.setHeaderField("Content-Type",
>> "application/x-java");
>>      ObjectOutputStream out = new
>> ObjectOutputStream(conn.getOutputStream());
>>      out.writeObject(myObject);
>>      int status = conn.getResponseCode();
>>      if(isOK(status)) {
>>          InputStream in = conn.getInputStream();
>>         // Handle response here.
>>      }
>>
> That's fantastic! And what does the jsp side look
> like? I only know how to get data through
> getParameter...
>

Would use a Filter or Controller-Servlet to do this instead of a jsp myself,
but that's mostly a style issue.  In any case, the code is the same wherever
it lives:
  <%
       ObjectInputStream ins = new
ObjectInputStream(request.getInputStream());
       MyClass myObject = (MyClass)ins.readObject();
  %>

Of course, the definition of MyClass visible to the webapp has to be the
same as it is to the Applet for this to work.  Assuming that the definition
of MyClass is in the same jar as the Applet (say, applet.jar), then having
an identical copy of applet.jar in WEB-INF/lib should work.

>
> Thanks!
>>
>> > Very many thanks in advance!
>> >
>> > Dola
>> >
>> > __________________________________________________
>> > Do You Yahoo!?
>> > Tired of spam?  Yahoo! Mail has the best spam
>> protection around
>> > http://mail.yahoo.com
>>
>>
>>
>>
>>
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> [hidden email]
>> For additional commands, e-mail:
>> [hidden email]
>>
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Sending a lot of info the a jsp page

Tim Lucia
In reply to this post by Dola Woolfe
POST / GET from applet ?action=load (servlet side)

    try {
        out= new ObjectOutputStream(response.getOutputStream());
        logger.debug("Sending object to applet.");
        out.writeObject((Object)object);
        out.flush();
        return;
    }
    catch (IOException e){
        logger.debug("Exception " + e.getMessage());
    }

POST / GET from applet, ?action=save (servlet side)

    try  {
        ObjectInputStream in = new
ObjectInputStream(request.getInputStream());
        logger.debug("Receiving object from applet.");
        object = (Object)in.readObject();
    }
    catch (IOException e){
        logger.debug("Exception " + e.getMessage());
    }


-----Original Message-----
From: Dola Woolfe [mailto:[hidden email]]
Sent: Saturday, January 21, 2006 3:27 PM
To: Tomcat Users List
Subject: Re: Sending a lot of info the a jsp page




--- Bill Barker <[hidden email]> wrote:

>
> "Dola Woolfe" <[hidden email]> wrote in message
>
news:[hidden email]...

> > Hi,
> >
> > This question will reveal how little I know about networking or http
> > or something else.
> >
> > Basically I wrote an applet that sends data to a
> > servlet. I do it by forming a url with a query
> string
> > (GET). But this doesn't work when there's too much
> > data.
> >
> > What are my options?
> > Is it possible to use POST?
> > Or, better yet, is it possible to send a java
> object
> > by creating a socket connection with the servlet?
> >
>
> Actually, combining these two is often easiest (of
> course, your java Object
> must implement Serializable for this to work).
> Something like (Applet
> code):
>
>      URL servlet = new URL(getDocumentBase(), "/path/to/my/servlet");
>      HttpURLConnection conn =
> (HttpURLConnection)servlet.openConnection();
>      conn.setDoInput(true);
>      conn.setDoOutput(true);
>      conn.setRequestMethod("POST");
>      conn.setHeaderField("Content-Type",
> "application/x-java");
>      ObjectOutputStream out = new
> ObjectOutputStream(conn.getOutputStream());
>      out.writeObject(myObject);
>      int status = conn.getResponseCode();
>      if(isOK(status)) {
>          InputStream in = conn.getInputStream();
>         // Handle response here.
>      }
>
That's fantastic! And what does the jsp side look
like? I only know how to get data through
getParameter...


Thanks!

>
> > Very many thanks in advance!
> >
> > Dola
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
>
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [hidden email]
> For additional commands, e-mail:
> [hidden email]
>
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]