You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dola Woolfe <do...@yahoo.com> on 2006/01/20 23:02:49 UTC

Sending a lot of info the a jsp page

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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Sending a lot of info the a jsp page

Posted by Dola Woolfe <do...@yahoo.com>.

--- Leon Rosenberg <ro...@googlemail.com>
wrote:

> On 1/20/06, Dola Woolfe <do...@yahoo.com> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Sending a lot of info the a jsp page

Posted by Leon Rosenberg <ro...@googlemail.com>.
On 1/20/06, Dola Woolfe <do...@yahoo.com> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Sending a lot of info the a jsp page

Posted by Bill Barker <wb...@wilshire.com>.
"Dola Woolfe" <do...@yahoo.com> wrote in message 
news:20060121202636.28793.qmail@web51813.mail.yahoo.com...
>
>
> --- Bill Barker <wb...@wilshire.com> wrote:
>
>>
>> "Dola Woolfe" <do...@yahoo.com> wrote in message
>>
> news:20060120220249.23681.qmail@web51813.mail.yahoo.com...
>> > 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:
>> users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail:
>> users-help@tomcat.apache.org
>>
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Sending a lot of info the a jsp page

Posted by Tim Lucia <ti...@yahoo.com>.
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:dolachin@yahoo.com] 
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 <wb...@wilshire.com> wrote:

> 
> "Dola Woolfe" <do...@yahoo.com> wrote in message
>
news:20060120220249.23681.qmail@web51813.mail.yahoo.com...
> > 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:
> users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail:
> users-help@tomcat.apache.org
> 
> 


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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Sending a lot of info the a jsp page

Posted by Dola Woolfe <do...@yahoo.com>.

--- Bill Barker <wb...@wilshire.com> wrote:

> 
> "Dola Woolfe" <do...@yahoo.com> wrote in message 
>
news:20060120220249.23681.qmail@web51813.mail.yahoo.com...
> > 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:
> users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail:
> users-help@tomcat.apache.org
> 
> 


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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Sending a lot of info the a jsp page

Posted by Bill Barker <wb...@wilshire.com>.
"Dola Woolfe" <do...@yahoo.com> wrote in message 
news:20060120220249.23681.qmail@web51813.mail.yahoo.com...
> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Sending a lot of info the a jsp page

Posted by Glen Mazza <gr...@verizon.net>.
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org