File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to connect a URL to a class file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to connect a URL to a class file" Watch "How to connect a URL to a class file" New topic
Author

How to connect a URL to a class file

Andy Canfield
Greenhorn

Joined: Nov 14, 2010
Posts: 4
My question is: How to get the URL
      http://localhost/Alpha
(no :8080) to run the Java servlet
      /MyPath/Whatever/Beta.class
What is the chain of linkages required?

I don't use CVS, I don't use Ant, I don't use JSP,
I am not using the Tomcat Manager.
But I can be root and edit any file on the hard disk.
Yes I've read the Tomcat documentation.
it is tool-oriented and confused and sometimes wrong.

I have Ubuntu Linux 10.04
and Apache 2.2.14
and Tomcat6 6.0.24.

FYI I can configure apache2 to alias /Alpha to /MyPath
and so it run /MyPath/index.php which consists of
      <?php
      system( "java Beta" )
      ?>
but in that case Beta is not a sevlet,
just an ordinary Java program.

FYL I've been writing PHP for several years.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Chnage Tomcat to listen on port 80 and map the servlet properly in the deployment descriptor.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Andy Canfield
Greenhorn

Joined: Nov 14, 2010
Posts: 4
Bear Bibeault wrote:Chnage Tomcat to listen on port 80


I can try this. But won't it interfere with Apache serving up my other web sites? On the web is a blog from 2001 saying that to get Apache to talk to Tomcat I have to recompile Apache, but of course that is rediculous.

Bear Bibeault wrote: map the servlet properly in the deployment descriptor.


By "deployment descriptor" do you mean
$CATALINA_BASE/conf/server.xml
or $CATALINA_BASE/conf/web.xml
or $CATALINA_HOME/webapps/default_root/META-INF/context.xml
or /MyPath/WEB-INF/web.xml
or /MyPath/META-INF/context.xml

The sample web.xml file has sample <servlet-mapping> entries but they do not seem to have any concept of a disk directory. So how does Apache (or Tomcat) know that when it sees "Alpha" it must look to "/MyPath"?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
No, you don't need to recompile Apache to have it use a Tomcat instance handle servlet requests; see http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html for all you need to know about the integration.

The DD for your web app would be /MyPath/WEB-INF/web.xml. In it you need appropriate <servlet> and <servlet-mapping> elements; if you're not sure how those work, see the servlets-examples web app that comes with Tomcat, or consult a servlet tutorial.
 
Don't get me started about those stupid light bulbs.
 
subject: How to connect a URL to a class file