Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets are not accessible but jsps are accessible.  RSS feed

Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!