• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

web.xml within tomcat

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, guys:
I wanted to put some code in tomcat/webapps/, I got a folder named 'test' within 'webapps', such as: webapps/test/, then I put .class files to webapps/test/WEB-INF/classes/;
for example: webapps/test/WEB-INF/classes/1.class;
webapps/test/WEB-INF/classes/A/2.class;
webapps/test/WEB-INF/classes/B/3.class;
The process flow is 1 call 2, then call 3.
I worte the file web.xml in WEB-INF; after starting tomcat, I used http://localhost:8080/test/1; I got 1, but the browser can not find 2. I do not know why. Acctually, I wrote <servlet-class> A.2</servlet-class>. So, Do you know how to descript the web.xml.

I know you guys have a lot of good idea, please give me some hint. or give me some reference files. Thanks!

Ellen
 
Saloon Keeper
Posts: 23544
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The location of the files in the WEB-INF/classes directory has to be exactly that which satifies classpath rules - If you have a file: WEB-INF/classes/A/1.class, then its package name must be
specified in the source code as "package A;" and its class name must, of course be "public class 1 {..." (well, actually a legal java name)
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In other words your web.xml should look something like this
<web-app>
<servlet>
<servlet-name>2</servlet-name>
<servlet-class>A.2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>2</servlet-name>
<url-pattern>2</url-pattern>
</servlet-mapping>
</web-app>
to invoke it you should have http://localhost:8080/2
 
reply
    Bookmark Topic Watch Topic
  • New Topic