Java and HTML clients of Web Server possible?

P

Paul Smith

Hello,

I have a Java client/server application. I am making changes to the
server piece so that it can be accessed from an HTML client. I am
using Tomcat on the server side. Although I can have a single code
base on the server side, is it possible to have only one instance of
the server servicing both the HTML clients and Java clients? As I see
it at the moment, I'll have to have my Java server running servicing
the Java clients, and my Tomcat server running servicing the HTML
clients. Because of the nature of the server, it is not ideal to have
two of them (the server caches certain data for a start!). So I would
like to have the Tomcat server service both HTML and Java client
requests, but I can't quite get my head round how to do that. I guess
my server code would have to determine whether the request had come
from a Java client (in which case coarse XML is returned to the
intelligent client for processing) or from an HTML client, in which
case the coarse XML returned from the business objects in response to
the request is formatted using XSLT into simple HTML for display on
the thin, un-intelligent, client browser.

Can anyone give me any constructive pointers?

Thanks,
Paul
 
J

Jose Rubio

Can you explain what the HTMl client and the Java client is? Is the HTML
client a browser accessing Java servlets and the Java client a standalone
Java application access a standalone server? How is the client/server
communication accomplished, sockets, CORBA, RMI, HTTP?
 
A

Anton Spaans

If i understand you correctly:

You want to figure out what client issued the request in your Tomcat Server,
you want to be able to tell whether a browser (IE, Netscape, Mozilla, etc.)
or a Java program issued the request?

I assume that both type of clients issue HTTP requests.
If so, examing the User-Agent header of the request. Get the value of this
header (for example, IE6.0 may return "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.0)").
Then based on this value, determine what type of client sent the request.

-- Anton.
 
J

John C. Bollinger

Paul said:
Hello,

I have a Java client/server application. I am making changes to the
server piece so that it can be accessed from an HTML client. I am
using Tomcat on the server side. Although I can have a single code
base on the server side, is it possible to have only one instance of
the server servicing both the HTML clients and Java clients? As I see
it at the moment, I'll have to have my Java server running servicing
the Java clients, and my Tomcat server running servicing the HTML
clients. Because of the nature of the server, it is not ideal to have
two of them (the server caches certain data for a start!). So I would
like to have the Tomcat server service both HTML and Java client
requests, but I can't quite get my head round how to do that. I guess
my server code would have to determine whether the request had come
from a Java client (in which case coarse XML is returned to the
intelligent client for processing) or from an HTML client, in which
case the coarse XML returned from the business objects in response to
the request is formatted using XSLT into simple HTML for display on
the thin, un-intelligent, client browser.

Can anyone give me any constructive pointers?

You can run your server inside Tomcat's JVM. The most appropriate way
to do so would probably be to start it as or with a
ServletContextListener declared by your webapp. The server could
operate within Tomcat's context as long as it is not contending with
Tomcat for the service port (which would be a potential issue no matter
where the server runs).

If both types of clients use HTTP as a transport protocol on the same
server port then it is necessary that they be served by a unified
server, in which case the servlet front-end for the service would need
to identify the client type and apply the XSL transformation for the
clients that need it.

If the "Java clients" use a different port then that side can probably
continue to work in the Tomcat environment with no change, and the
servlet front-end for browser clients can always transform the raw XML
without worrying about client identification.


You can also run the server standalone, in a separate VM, and let the
servlet front-end for browser requests just proxy for the regular
server. That might be easier to implement (although not _that_ much
easier).


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top