File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Servlets are not accessible but jsps are accessible. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Servlets are not accessible but jsps are accessible." Watch "Servlets are not accessible but jsps are accessible." New topic

Servlets are not accessible but jsps are accessible.

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205

Please help me out resolving the below issues - Just now i have installed tomcat 5.0, through the url i couldn't access any of my own servlets and also examples that were installed through tomcat installation but through the url i could access the jsps. Here is the tree structure of my servlet class file,
In the URL i am giving the path as,
I am getting the error as "The requested resource (/ch1/Ch1Servlet) is not available."
Even this problem persist with the tomcat examples, One of the servlet class is located at --
I am trying to access this servlet through -
but i am getting the error -
"The requested resource (/servlets-examples/HelloWorldExample) is not available."
But i could access successfully jsps, please help me out in resolving the issue.
Thanks in Advance

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
I think both of those problems are due to the fact that the servlets are not in packages. Prior to Tomcat 4 you were able to address servlets that are not in packages by means of the "invoker" servlet. This "convenience" has caused vast frustration for people starting in servlets since the invoker is now off by default in Tomcat. See this JavaRanch FAQ on the invoker.
All classes used in servlets should be in packages - of course the directory path under WEB-INF/classes must reflect that.
Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
Hi Narasimha

I have some useful points for Tomcat...and am sending the same to you.
Check them and out and try again.

The things that we have to look into while creating our own web apps are

1. The directory structure is proper
say some c:\Tomcat\webapps\OwnApp
2. Then inside our application, we need to create a web-inf
say c:\Tomcat\webapps\OwnApp\WEB_INF
3. Then we can arrange our own things here in this space

a. Java Script Files
say c:\Tomcat\webapps\OwnApp\WEB_INF\script - say

b. CSS
say c:\Tomcat\webapps\OwnApp\WEB_INF\css - Say

c. Images
say c:\Tomcat\webapps\OwnApp\WEB_INF\Images - say

d. Of course our servlets will be in the classes folder

say c:\Tomcat\webapps\OwnApp\WEB_INF\classes.

e. And beans in a package
say c:\Tomcat\webapps\OwnApp\WEB_INF\classes\mypack\mybeans\com\SomeBeanClass

And don't forget to have ur own web.xml configured for ur new servlets....

I agree. Here's the link:
subject: Servlets are not accessible but jsps are accessible.
It's not a secret anymore!