You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leslie Yu <le...@hkcts.com> on 2002/08/13 07:09:02 UTC

Is Struts suitable for Java client?

Hi all,

    I'm going to develop a java application with java client on client side
which talks to a controller servlet. The data transmitted between client and
server may be serialized object.
    Does Struts support java client by outputting a serialized object as a
HTTP response instead of forwarding to a JSP? If yes, would anyone give me
some hints? Thanks.

Best Regards,
Leslie


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Interoperability of Struts and SOAP [Was: Is Struts suitable for Java client?]

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 14 Aug 2002, John Yu wrote:

> Date: Wed, 14 Aug 2002 18:50:21 +0800
> From: John Yu <jo...@scioworks.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Interoperability of Struts and SOAP [Was: Is Struts suitable
>     for Java client?]
>
>
> Craig,
>
> This reminds me this message:
>
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=struts-dev@jakarta.apache.org&msgNo=8784
>
> Is this anywhere near what you have in mind?

That's definitely one approach to the same problem space.  A key, in my
mind, is one of the points Kevin made -- "Struts users shouldn't have to
know how to encode the XML response" (or parse the XML request, for that
matter).


> --
> John

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Interoperability of Struts and SOAP [Was: Is Struts suitable for Java client?]

Posted by John Yu <jo...@scioworks.com>.
Craig,

This reminds me this message:

http://nagoya.apache.org/eyebrowse/ReadMsg?listName=struts-dev@jakarta.apache.org&msgNo=8784

Is this anywhere near what you have in mind?
--
John


At 12:53 pm 14-08-2002, Craig wrote:

>(Broad hint for a future direction for Struts -- would you like to create
>Struts-based applications that can make their underlying information
>available via both interactive apps as HTML, and web services using SOAP
>formats?  And be interoperable with JAX-RPC?  I would like that also.
>Stay tuned ...)

-- 
John Yu                       Scioworks Technologies
e: john@scioworks.com         w: +(65) 873 5989
w: http://www.scioworks.com   m: +(65) 9782 9610 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Is Struts suitable for Java client?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 14 Aug 2002, Leslie Yu wrote:

> Date: Wed, 14 Aug 2002 14:49:33 -0700
> From: Leslie Yu <le...@hkcts.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Is Struts suitable for Java client?
>
> Hi all,
>
>     Thank you so much for your replies. I have one more question about the
> java client and server communication in Struts.
> Can I send serialized object from java client to the controller servlet?
> After studying the Struts documentation, I get an idea that the ActionForm
> class will only capture the HTML form field values from the
> HttpServletRequest. And the Action class will get the data from the
> ActionForm. Does it mean that in order to let the java client talk to the
> controller servlet successfully, we need to simulate the HTML form POST
> action in the client? Can the Action class receive a serialized object sent
> from the client?
>     Thanks in advance.
>

At least two different approaches seem feasible:

* Dispense with form beans, and let your Action read the
  serialized data directly out of the request (easy to do
  since that is one of the parameters to the action)

* Have your Java client format the request data like a file
  upload, using multipart/form-data.  Then, you can leverage
  the existing Struts support for this.

> Best regards,
> Leslie
>

Craig


> ----- Original Message -----
> From: "Craig R. McClanahan" <cr...@apache.org>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, August 13, 2002 9:53 PM
> Subject: Re: Is Struts suitable for Java client?
>
>
> >
> >
> > On Wed, 14 Aug 2002, John Yu wrote:
> >
> > > Date: Wed, 14 Aug 2002 12:25:02 +0800
> > > From: John Yu <jo...@scioworks.com>
> > > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> > > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > > Subject: Re: Is Struts suitable for Java client?
> > >
> > > You can return binary data from the Actions. In the action's
> > > perform()/execute(), instead of returning a forward mapping, what you
> can
> > > do is:
> > >     * Set the correct content type and header by calling
> > > response.setContentType() and setHeader()
> > >     * Get the output stream from response.getOutputStream() and stream
> > > whatever binary data you need to return
> > >     * at the end of the perform()/execute() method, return null.
> >
> > John is spot on in describing the mechanics of meeting this need.  A
> > little more background information on why Struts works this way might be
> > useful to you, and to others considering web "applications" that do not
> > emit HTML directly.
> >
> > The general MVC model that Struts encourages is to have your Action
> > perform the business operations related to a particular request, but not
> > to get involved in creating the actual response.  Instead, the normal
> > pattern is to forward to some other resource in the webapp (typically, but
> > not necessarily, a JSP page).  For example, you can forward to a servlet
> > that produces binary output.
> >
> > However, Struts does not *force* you to take this approach.  In general,
> > returning null from your Action.perform() or Action.execute() method says
> > "I have already taken care of producing the response -- there is no need
> > for any further processing".
> >
> > Some example scenarios where this might be better than forwarding to a
> > different resource to produce the response content:
> >
> > * Your Action decides that a redirect to some other (internal or
> >   external) URL is appropriate.  If the Action has called
> >   response.sendRedirect(), you don't need or want to have some other
> >   webapp resource try to create a response that isn't going to be seen
> >   in any event.
> >
> > * Your Action is creating a dynamic image (such as the graph from a
> >   live stock price tracking application -- although for most stocks,
> >   including SUNW (my employer), I don't really want to see the recent
> >   graphs, thank you :-).  If your Action writes the binary data for this
> >   graph directly to the response, there is no need for a separate
> >   resource to produce it.
> >
> > * Your action is creating a response stream containing a serialized
> >   Java object (such as when you are talking to an applet).  If your
> >   Action does this directly, you won't want to forward to a JSP page
> >   anyway -- the response has already been created.
> >
> > * Your Action creates a response that is going to be transformed by a
> >   Filter before being returned to a client (such as the common scenario
> >   where your Action returns XML data that will be transformed by a Filter
> >   depending on what kind of client device is making the request).  This
> >   will be a common scenario when the business logic of your application
> >   wants to create XML data in some standardized format that is transformed
> >   into browser-specific (or wireless-device-specific) HTML or WML by an
> >   external filter.  (Note that you can still use a JSP page to do this
> >   sort of XML output with interspersed dynamic output via custom tags;
> >   the point is that you might be rendering the output from something like
> >   an XML DOM tree that is dynamically generated by your Action).
> >
> > (Broad hint for a future direction for Struts -- would you like to create
> > Struts-based applications that can make their underlying information
> > available via both interactive apps as HTML, and web services using SOAP
> > formats?  And be interoperable with JAX-RPC?  I would like that also.
> > Stay tuned ...)
> >
> > Craig McClanahan
> >
> >
> >
> >
> > > At 01:09 pm 13-08-2002, you wrote:
> > > >Hi all,
> > > >
> > > >     I'm going to develop a java application with java client on client
> side
> > > >which talks to a controller servlet. The data transmitted between
> client and
> > > >server may be serialized object.
> > > >     Does Struts support java client by outputting a serialized object
> as a
> > > >HTTP response instead of forwarding to a JSP? If yes, would anyone give
> me
> > > >some hints? Thanks.
> > > >
> > > >Best Regards,
> > > >Leslie
> > > >
> > > >
> > > >--
> > > >To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > >For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > >
> > > --
> > > John Yu                       Scioworks Technologies
> > > e: john@scioworks.com         w: +(65) 873 5989
> > > w: http://www.scioworks.com   m: +(65) 9782 9610
> > >
> > > Scioworks Camino - "Don't develop Struts Apps without it!"
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Is Struts suitable for Java client?

Posted by Leslie Yu <le...@hkcts.com>.
Hi all,

    Thank you so much for your replies. I have one more question about the
java client and server communication in Struts.
Can I send serialized object from java client to the controller servlet?
After studying the Struts documentation, I get an idea that the ActionForm
class will only capture the HTML form field values from the
HttpServletRequest. And the Action class will get the data from the
ActionForm. Does it mean that in order to let the java client talk to the
controller servlet successfully, we need to simulate the HTML form POST
action in the client? Can the Action class receive a serialized object sent
from the client?
    Thanks in advance.

Best regards,
Leslie

----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, August 13, 2002 9:53 PM
Subject: Re: Is Struts suitable for Java client?


>
>
> On Wed, 14 Aug 2002, John Yu wrote:
>
> > Date: Wed, 14 Aug 2002 12:25:02 +0800
> > From: John Yu <jo...@scioworks.com>
> > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > Subject: Re: Is Struts suitable for Java client?
> >
> > You can return binary data from the Actions. In the action's
> > perform()/execute(), instead of returning a forward mapping, what you
can
> > do is:
> >     * Set the correct content type and header by calling
> > response.setContentType() and setHeader()
> >     * Get the output stream from response.getOutputStream() and stream
> > whatever binary data you need to return
> >     * at the end of the perform()/execute() method, return null.
>
> John is spot on in describing the mechanics of meeting this need.  A
> little more background information on why Struts works this way might be
> useful to you, and to others considering web "applications" that do not
> emit HTML directly.
>
> The general MVC model that Struts encourages is to have your Action
> perform the business operations related to a particular request, but not
> to get involved in creating the actual response.  Instead, the normal
> pattern is to forward to some other resource in the webapp (typically, but
> not necessarily, a JSP page).  For example, you can forward to a servlet
> that produces binary output.
>
> However, Struts does not *force* you to take this approach.  In general,
> returning null from your Action.perform() or Action.execute() method says
> "I have already taken care of producing the response -- there is no need
> for any further processing".
>
> Some example scenarios where this might be better than forwarding to a
> different resource to produce the response content:
>
> * Your Action decides that a redirect to some other (internal or
>   external) URL is appropriate.  If the Action has called
>   response.sendRedirect(), you don't need or want to have some other
>   webapp resource try to create a response that isn't going to be seen
>   in any event.
>
> * Your Action is creating a dynamic image (such as the graph from a
>   live stock price tracking application -- although for most stocks,
>   including SUNW (my employer), I don't really want to see the recent
>   graphs, thank you :-).  If your Action writes the binary data for this
>   graph directly to the response, there is no need for a separate
>   resource to produce it.
>
> * Your action is creating a response stream containing a serialized
>   Java object (such as when you are talking to an applet).  If your
>   Action does this directly, you won't want to forward to a JSP page
>   anyway -- the response has already been created.
>
> * Your Action creates a response that is going to be transformed by a
>   Filter before being returned to a client (such as the common scenario
>   where your Action returns XML data that will be transformed by a Filter
>   depending on what kind of client device is making the request).  This
>   will be a common scenario when the business logic of your application
>   wants to create XML data in some standardized format that is transformed
>   into browser-specific (or wireless-device-specific) HTML or WML by an
>   external filter.  (Note that you can still use a JSP page to do this
>   sort of XML output with interspersed dynamic output via custom tags;
>   the point is that you might be rendering the output from something like
>   an XML DOM tree that is dynamically generated by your Action).
>
> (Broad hint for a future direction for Struts -- would you like to create
> Struts-based applications that can make their underlying information
> available via both interactive apps as HTML, and web services using SOAP
> formats?  And be interoperable with JAX-RPC?  I would like that also.
> Stay tuned ...)
>
> Craig McClanahan
>
>
>
>
> > At 01:09 pm 13-08-2002, you wrote:
> > >Hi all,
> > >
> > >     I'm going to develop a java application with java client on client
side
> > >which talks to a controller servlet. The data transmitted between
client and
> > >server may be serialized object.
> > >     Does Struts support java client by outputting a serialized object
as a
> > >HTTP response instead of forwarding to a JSP? If yes, would anyone give
me
> > >some hints? Thanks.
> > >
> > >Best Regards,
> > >Leslie
> > >
> > >
> > >--
> > >To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > >For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> > --
> > John Yu                       Scioworks Technologies
> > e: john@scioworks.com         w: +(65) 873 5989
> > w: http://www.scioworks.com   m: +(65) 9782 9610
> >
> > Scioworks Camino - "Don't develop Struts Apps without it!"
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Is Struts suitable for Java client?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 14 Aug 2002, John Yu wrote:

> Date: Wed, 14 Aug 2002 12:25:02 +0800
> From: John Yu <jo...@scioworks.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Is Struts suitable for Java client?
>
> You can return binary data from the Actions. In the action's
> perform()/execute(), instead of returning a forward mapping, what you can
> do is:
>     * Set the correct content type and header by calling
> response.setContentType() and setHeader()
>     * Get the output stream from response.getOutputStream() and stream
> whatever binary data you need to return
>     * at the end of the perform()/execute() method, return null.

John is spot on in describing the mechanics of meeting this need.  A
little more background information on why Struts works this way might be
useful to you, and to others considering web "applications" that do not
emit HTML directly.

The general MVC model that Struts encourages is to have your Action
perform the business operations related to a particular request, but not
to get involved in creating the actual response.  Instead, the normal
pattern is to forward to some other resource in the webapp (typically, but
not necessarily, a JSP page).  For example, you can forward to a servlet
that produces binary output.

However, Struts does not *force* you to take this approach.  In general,
returning null from your Action.perform() or Action.execute() method says
"I have already taken care of producing the response -- there is no need
for any further processing".

Some example scenarios where this might be better than forwarding to a
different resource to produce the response content:

* Your Action decides that a redirect to some other (internal or
  external) URL is appropriate.  If the Action has called
  response.sendRedirect(), you don't need or want to have some other
  webapp resource try to create a response that isn't going to be seen
  in any event.

* Your Action is creating a dynamic image (such as the graph from a
  live stock price tracking application -- although for most stocks,
  including SUNW (my employer), I don't really want to see the recent
  graphs, thank you :-).  If your Action writes the binary data for this
  graph directly to the response, there is no need for a separate
  resource to produce it.

* Your action is creating a response stream containing a serialized
  Java object (such as when you are talking to an applet).  If your
  Action does this directly, you won't want to forward to a JSP page
  anyway -- the response has already been created.

* Your Action creates a response that is going to be transformed by a
  Filter before being returned to a client (such as the common scenario
  where your Action returns XML data that will be transformed by a Filter
  depending on what kind of client device is making the request).  This
  will be a common scenario when the business logic of your application
  wants to create XML data in some standardized format that is transformed
  into browser-specific (or wireless-device-specific) HTML or WML by an
  external filter.  (Note that you can still use a JSP page to do this
  sort of XML output with interspersed dynamic output via custom tags;
  the point is that you might be rendering the output from something like
  an XML DOM tree that is dynamically generated by your Action).

(Broad hint for a future direction for Struts -- would you like to create
Struts-based applications that can make their underlying information
available via both interactive apps as HTML, and web services using SOAP
formats?  And be interoperable with JAX-RPC?  I would like that also.
Stay tuned ...)

Craig McClanahan




> At 01:09 pm 13-08-2002, you wrote:
> >Hi all,
> >
> >     I'm going to develop a java application with java client on client side
> >which talks to a controller servlet. The data transmitted between client and
> >server may be serialized object.
> >     Does Struts support java client by outputting a serialized object as a
> >HTTP response instead of forwarding to a JSP? If yes, would anyone give me
> >some hints? Thanks.
> >
> >Best Regards,
> >Leslie
> >
> >
> >--
> >To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> --
> John Yu                       Scioworks Technologies
> e: john@scioworks.com         w: +(65) 873 5989
> w: http://www.scioworks.com   m: +(65) 9782 9610
>
> Scioworks Camino - "Don't develop Struts Apps without it!"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Is Struts suitable for Java client?

Posted by John Yu <jo...@scioworks.com>.
You can return binary data from the Actions. In the action's 
perform()/execute(), instead of returning a forward mapping, what you can 
do is:
    * Set the correct content type and header by calling 
response.setContentType() and setHeader()
    * Get the output stream from response.getOutputStream() and stream 
whatever binary data you need to return
    * at the end of the perform()/execute() method, return null.
At 01:09 pm 13-08-2002, you wrote:
>Hi all,
>
>     I'm going to develop a java application with java client on client side
>which talks to a controller servlet. The data transmitted between client and
>server may be serialized object.
>     Does Struts support java client by outputting a serialized object as a
>HTTP response instead of forwarding to a JSP? If yes, would anyone give me
>some hints? Thanks.
>
>Best Regards,
>Leslie
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
John Yu                       Scioworks Technologies
e: john@scioworks.com         w: +(65) 873 5989
w: http://www.scioworks.com   m: +(65) 9782 9610

Scioworks Camino - "Don't develop Struts Apps without it!"