• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet Servlet communication with struts?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi *,

I'm looking for some information/web sites, how to program a
Applet Servlet communication using the struts framework.
Can you give me some links?

Best,

Torsten
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont know if struts has any special facilities for this, but here is a pretty good article that discusses applet-servlet communication in general.


Applet-to-Servlet Communication for Enterprise Applications


Apparantly someone else found it very useful too http://milinddev.tripod.com/appletservlet.htm
 
Torsten Schindler
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

thanks for the fast answer. I already know both articles and
have done some Applet-Servlet programming for a project myself.
Maybe I formulated my question wrong. Sorry for this!!!

I'm especially interested in Applets which interact with
Servlets which use the Struts framework.
How to do ActionForwarding to an applet,
how to write the struts-config.xml file for such a case
and so on...

Regards,

Torsten
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We use the same framework. We create an object or collection to be returned to the Applet in the action, and then forward the object to the applet. To achieve this - we do the following:

1. From applet, we open the URLConnection with the URL for an Action.

2. At the end of Action class, we retrieve the object from middle tier (business logic tier)to be returned to the applet.

3. We use Castor to marshal the object to XML String and put the XML String in request attribute

4. We forward to "success" which is mapped to a jsp. The content of the jsp file is



5. The XML String now arrives to applet as input stream. Read the input stream from the URLConnection and form the XML String.

6. Use Castor unmarshal to get back the object in the Applet.

HTH.
 
Torsten Schindler
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Susanta.

Can you explain me step 3.-5. a little bit more in detail?
So, why do you use Castor and not normal object serialization?
Do you have a link or example source code?

Thanks,

Torsten
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Torsten,

Step 3 is required to convert the object to XML String. We tried with Java Object Serialization before, but at that time our development environment was VAJ 3.5.3 and the serialized object in VAJ Test Environment had problem while being unmarshalled in Sun 1.4.1 JDK - I do not remember the exact exception message, but as far as I can recall, we used to get Corrupted Stream exception. But, if effect, that would throw us out of VAJ IDE.
We also tried JSX, instead of Castor, and JSX works too. You could use JSX or any other kind of XML Serialization.

Regarding, Step 4 and 5 - as the HTTP Connection originated from Applet, hence, all the response will end up going to the URLConnection input stream of the Applet, which initiated the connection. No matter, where you forward your response to, the response stream could be read by reading on input stream of the URLConnection.

Here is example code from applet,



Now, we have byte array from the response, convert the array to String, which is really the object marshalled to XML.

Hope this helps.
 
reply
    Bookmark Topic Watch Topic
  • New Topic