Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

using servlets in Jboss-tomcat

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Please help me on this. This is urgent.
I am using jboss-3.2.1_tomcat-4.1.24 version and I made a simple web application and put the war file in JBOSS\server\default\deploy directory.
WEB-INF\web.xml
WEB-INF\classes\TestServlet
is my directory structure of my war and my web.xml is
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
</web-app>
If i start the jBoss, I see my test.war being deployed fine. But, if Iaccess it as http://localhost:8080/test/servlet/TestServlet
froma browser, I get a 404 error and jBoss console says
"mapping error for URI /test/servlet/TestServlet"
I then tried adding a servlet-mapping to my web.xml by adding
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Now, if I access using the URL http://localhost:8080/test/, it goes to the testServlet page. I need to add more serlvlets now. This mapping is not right. Books i read say that without mapping itself, we should be able to access the servlet, but I always get 404 and mapping error of URI. What do i do. Please help me soon.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried http://localhost:8080/test/TestServlet?
You can then add more servlets like this:
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>TestServlet2</servlet-name>
<servlet-class>TestServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TestServlet2</servlet-name>
<url-pattern>/TestServlet2</url-pattern>
</servlet-mapping>
Hope it helps.
 
Sara Bose
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I did try http://localhost:8080/test/TestServlet. It also said the same mapping URI error.
Now I fixed by doing what you said, having a <url-mapping> for all of them. I consider this to be a hack. It works, but this not the way we usually do when we use tomcat seperately right. With just <servlet></servlet> mapping it would work, if the class is in application/classes dir. Why does it not work so with JBoss implementation now?
Thanks
 
Maya Bose
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right, it should work. Only other thing I can think of is: check the full package name of the servlet exists in the <servlet>.
 
Sara Bose
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not have any package where classes are. I just have 2 servlet's .class file in
WEB-INF/classes directory. No packages. So my web.xml just lists them both and I am not able to access as I could do in tomcat by http://localhost:8080/<app>/servlet/servletname
I had to put explicit url-mapping to eac of them now. Why?
 
money grubbing section goes here:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic