tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From puneet sachar <puneetsac...@yahoo.com>
Subject tomcat Sloutions
Date Wed, 02 Jan 2002 18:41:04 GMT
hi Tom

now listen for that question i have make a small
solutions

guide me what is good and what u feel is the right way

u know the question what i was asking 

here it again 
Plz all u devloper just look at it

To the technical team Tomcat ,

Sir I have a problem, I'm using tomcat server 3.3 ,
now I have 3 different application rather one
application witrh different version 
Say for client A I have some classes that is version
1.0
For client B I have some classes that is version 2.0
which have might have exactly same classes that is
present in version 1.o or modified classes as required
by client B and some extra classes
And for Client C I have version 3.0 which again might
have same classes or modified classes .

Now I problem is I have to run that application on
same tomcat server but I want different application
only respond to their classes 

Is it I have to add 3 different JVM for different for
different classes or different Servlets context for
different classes and how would I add 3 different JVM
in one container.

If u doesn't follow my question please take this case
study

As I mention I have 3 different applications running
on my tomcat each have same class A
And Class A for client A prints "in client A"
For Class A for client B prints "in client B"
And For Class A for client C prints "in client C"

And suppose if class A is called by any one of client
which is print..

{According to me the class, which is set in class
path, is to be printed and I want classes should
respond to respective classes} 

Please Sir I 'm stuck because of this problem looking
forward for your suggestions

here are the solutions

under this ******** i have my comments

here it goes


Scenario 

Stand-alone HTTP based application and web server,
multiple applications having same class name.

Solutions 

1)Follow the package rule where different application
lies in different package/folder and by using the
method
InetAddress.getByName(ServletRequest.getRemoteAddr())
forward the request to corresponding client folder. 

Vineet's Argument :- if there are 3 classes named by A
for 3 different client under one http server and
having output as printing client name on console 

class A
{
	A()
	{
		
	
System.out.println(InetAddress.getByName(ServletRequest.getRemoteAddr());
	}
} 

	
Choosing the class path at runtime to after the client
has send the request to the server is not possible
unless u have your own batch file "chose.bat" which
will choose the jvm for the client/ context for a
client to pick that particular servlets A.class
mention in the folder for that client .

So at the first request when client contact the server
call a java program that will run that batch file
using Runtime class 
Runtime r=Runtime.getRuntime();
Process p=r.exec("/choose.bat");

******************************************************
In case of windows the server already started on a
autoexec.bat to run more batch file on current batch
file, then we don't have to mention a classpath in
autoexec and it will decide once the client sends
request. 

But I really have some doubt in this technique,
anyways just let me know if you think this goanna
work, then I'll concentrate more on this logic or
trick or something near like thatů.
*******************************************************

2)Place different application under different Folder
(don't write any new package name) Just add the
concept of virtual host 
Like provide the client A with virtual host as
www.clientA.com 
Similarly provide client B with www.clientB.com 
And client C with www.clientC.com 

A Host component represents a "virtual host" that is
running in an instance of Catalina, possibly in
conjunction with many other virtual hosts. Each
virtual host can be running one or more web
applications, each represented by a Context component.
In order for a client, such as a web browser, to
successfully send a request to a web application
running in a particular virtual host, the client must
specify a hostname that is mapped, in the Domain Name
Service (DNS) to the server that Catalina is running
on, and a port number on which you have defined a
Connector to be listening. 

And just add few changes in server.xml file under
conf/server.xml as 

<Host name="localhost" debug="0" appBase="webapps">
 where 

appBase is The "application base" directory for this
virtual host. This is the pathname of a directory that
may contain web applications to be executed in this
virtual host. 

Name is The host name of this virtual host. This name
must match the name submitted on the Host: header in
incoming requests. This attribute is required, and
must be unique among the virtual hosts running in this
servlet container.

Root is Boolean attribute stating whether calls to
ServletContext.getContext() on web applications
running in this virtual host should allow one
application to gain access to the ServletContext of
another. Set to false to disallow such access. 

This can be done if Application for client B need some
files present in Context for client A

*******************************************************
In this we don't have to rewrite the different package
names just follow the same convention naming as
followed by every application 
Just the application directory will be different 

The DNS server itself redirects the request to
corresponding application
********************************************************

3)Using HTTP/1.1 Connector component 

The HTTP/1.1 Connector component is a Connector
implementation that supports the HTTP/1.1 protocol. It
enables Catalina to function as a stand-alone web
server, in addition to its ability to execute servlets
and serve JSP pages.

 A particular instance of this component listens for
connections on a configured TCP/IP port number on the
server. One or more such connectors can be configured,
each forwarding requests to a particular Container for
processing.

This Connector is configured by including a
<Connector> element in conf/server.xml configuration
file, nested inside the <Server> element. 

Default -->

 Defining the Tomcat Stand-Alone Service 
 
<Service name="Tomcat-Standalone">
<Connector
className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0" />

Define an application for client A Connector on port
8000

<Connector
className="org.apache.catalina.connector.http.HttpConnector"
port="8000" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0" />

Followed by
ENGINE ELEMENT 

An Engine represents the entry point (within Catalina)
that processes every request. The Engine
implementation for Tomcat stand alone analyzes the
HTTP headers included with the request, and passes
them on to the appropriate Host (virtual host). 

Defining the top level container in our container
hierarchy 
  
<Engine name="Standalone"
defaultHost="www.clientA.com" debug="0">

<Host name="www.clientA.com" debug="0"
appBase="webapps">
and then followed by

Tomcat Context 

<Context path="/ANY DRIVE" docBase="examples"
debug="0" reloadable="true">
and then 
</Context>
</Host>
</Engine>
</Service> closing the tags 

********************************************************
Like what we used to do incase of websphere 3.0 
Changes made to host file in winnt of NT machine and
httpd.config in websphere 3.0 root file 

Document root -c:\abc
Classpath -c:/abc/servlets
Classpath in use -c:/abc/servlets
Web Application name : Puneet
Virtual Host : default host
Web Application Web Path - /Puneet
Full path in use -/Puneet 

Thus www.puneet.com the server will map to resource
located at c:/abc for html/jsp and c:/abc/servlets for
java file 
********************************************************

Good Morning here is the some solutions that I feel
can be done, Tomcat is totally new server for me this
I 'm able to collect from the documentations and
asking the views of other developers 

If any of the above solutions you feel cannot be done
on tomcat or cannot be done with the application you
are making do let me ůso that I have an idea what
exact we are looking for and I'm able to concentrate
on that logic  

But I feel the best way is to 
*******************************************************
We can simply package and deploy each set of classes
as a separate web application with it's own context
(e.g. a, b, and c). Under each context is a
WEB-INF/lib directory that would hold the jar file
that contains the correct versions of all the classes
used by that clients application. 

This way, when your user requests a URL from context
'a', the servlet, jsp, bean, ... code that handles the
request will be loaded from the jar file in the 'a'
context. Similarly for the the other contexts.

This will all run under one JVM, but each context will
be loaded via a different class loader.
********************************************************

If have also asked the tomcat technical team for the
solutions, their mail is still awaited and as soon
I'll get that mail I'll fwd it to you also.


Regards 
Puneet Sachar
e-Developer
Shyama Software Solutions
New Delhi 



__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message