• 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

How to connect a URL to a class file

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chnage Tomcat to listen on port 80 and map the servlet properly in the deployment descriptor.
 
Andy Canfield
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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"?
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic