• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Design problem web, application

 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I don't know the best approach to this problem. I'm building a web application JSP, Servlets, MYSQL with tomcat container.

The adminstration is in a normal Application to support integration with other desktop application and printing drag and drop and so on.

I want to use the same Objects in the application and JSP. What is the best approach.

Do I have to serialize all objects in the desktop application to communicate with servlets?

I don't have direct access to the mysql server because the port is closed just with servlets over port80. Anyone has suggestion on best approach

// Mathias
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sending serialized objects back and forth is one approach; another is to make the admin app just a "thin client" with everything happening on the server; the server would provide a separate, rich interface (via web services, perhaps) which the admin app would use to communicate with it. Personally I'd choose this latter approach.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I always like pictures. See if this looks like what Ernest said:

The browser uses standard HTTP and gets back HTML. I usually like a servlet that receives the request, delegates to a plain Java object that interacts with the services, and then forwards to a JSP that builds the HTML response.

The Swing client does all its own presentation so it doesn't need HTML. It uses HTTP GET and POST again to communicate with a servlet. This servlet delegates to a plain Java object that interacts with the services, but then returns XML.

The biggest difference might be the "thing" that converts service output to HTML in one case and XML in the other. Another difference is that the second servlet can be a lot simpler.

This is such a common scenario that there are many tools to help you expose services as web services and consume them from the client end. On the other hand, it's really very easy to build your own and probably worth the education you'd get the first time around.

Having fun yet?
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!

That all sound good but to be frank i don't really understand exactly what you are talking about. Perhaps I'm not quite that skilled in java yet.

I don't really have to use JSP because it is not a "real" web application
It is an applet that is signed. The applet interacts with servlets on another webserver. I have control over both of the servers.

What I mean is the users only use the applet. Drag and drop files drags boxes etc in the applet. The data needs to be saved to database. I can't communicate with the database directly from the applet because the users won't open the port in their firewall so it needs to be done over port 80.

// Mathias
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maybe im missing something here, but why not:

1. send the data from the applet to a servlet (HTTP port 80).
2. get the servlet to write the data to the database

then no need to mess around with any firewalls on client machines.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you communicate from the applet to a server now? With HttpURLConnection? In that case, it's working just as the "fat client" path I drew above.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Yes I use HTTPURLConnection to communicate with servlets. I set the content type to post and receive java objects. Rather tedious to copy all classes that needs to be serialized from servlet to applet though.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rather tedious to copy all classes that needs to be serialized from servlet to applet though.



Why is that? How do you "serialize" them across the wire? If you find XML too painful I won't disagree. Look at JSON for a simpler alternative.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I implement the Serializable interface and post them from applet to servlet. In the serlvet I receive the response cast the data and do the logic. Often I post back an object so that the applet knows that all was ok.
 
reply
    Bookmark Topic Watch Topic
  • New Topic