• 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

Basic doubt

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I was just wondering if it is possible to call a servlet from the browser directly without declaring it in the web.xml. If yes could someone please tell me how? Or else is this question web server specific?
I have been working with jsp and servlets for quite some time now but I have always called the servlets after I have declared them in the web.xml.
Thank you in advance
Lalitha Chandran
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
With Tomcat at least:
Suppose your webapp is mywebapp and you have a servlet named MyServlet in package com.mycompany, you can call the servlet by this URL:
http://localhost:8080/mywebapp/servlet/com.mycompany.MyServlet
Regards,
Cyril.
 
Lalitha Chandran
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cyril
Thank you for the response.
But I tried the same thing but couldn't get the output.
This is my folder structure
C:\Tomcat 4.1\webapps\ROOT\com
and I tried calling it from browser without declaring it in web.xml
http://localhost:8080/servlet/com.SimpleServlet
But I get the 404 error. I am using Tomcat 4.1.24
Regards
Lalitha Chandran
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you need to call
http://localhost:8080/ROOT/servlet/com.SimpleServlet
instead of
http://localhost:8080/servlet/com.SimpleServlet
hope this help
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your URL :
http://localhost:8080/servlet/com.SimpleServlet is the good one. No ROOT must appear here.
But in order to make it OK, you still have to modify your default file web.xml <%TOMCAT_HOME%>/conf/web.xml by deleting the commentary in the following section:
:
<!-- The mapping for the invoker servlet -->
Delete this <!--
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
Delete this -->
Hope this helps,
Regards,
CyriL
 
Lalitha Chandran
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cyril,
Thanks a lot for responding. It is now working after I uncommented the invoker portion from web.xml.
Thank you
Lalitha Chandran
 
reply
    Bookmark Topic Watch Topic
  • New Topic