Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets are not accessible but jsps are accessible.

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

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,
Installation_directory/webapps/ch1/WEB-INF/classes/Ch1Servlet.class
In the URL i am giving the path as,
http://localhost:8080/ch1/Ch1Servlet
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 --
install_directoty\webapps\servlets-examples\WEB-NF\classes\HelloWorldExample
I am trying to access this servlet through -
http://localhost:8080/servlets-examples/HelloWorldExample
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
Rancher
Posts: 13058
6
  • 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.
Bill
 
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....

Cheers,
Swamy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic