• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Unable to run servlet

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

could anyone tell me why when I try to run my servlet from browser I'm getting the following error:

HTTP: Status 404 -

type: Status report

message

description: The requested resource () is not available.
Apache Tomcat/5.5.27


What does the above line mean? What's wrong I'm doing here?

Thanks in advance.Pawan
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pawan Arora wrote:
What does the above line mean? What's wrong I'm doing here?



If you Googled HTTP: Status 404 the error code , you will find that, the the web app you are trying to access is not deployed by the server at all. That's mean for sure, there must be something went wrong while deploying your web app..

Whats the logs says ??
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure you got your 'Case' right. Tomcat and all Java servers are pretty case sensitive so if your web application is deployed inside a folder 'MyApp' and the servlet mapping is 'doStuff' you need to make sure that the link you are trying to hit is http://localhost:8080//MyApp/doStuff with no change in case.

localhost:8080 is assuming default configaration - Your's could be on a different port.
 
Pawan Arora
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

my compiled servlet class is in class folder and as far as I concerned I've done mapping of servlet name correctly too. Here is the code



and I try to access it with an address http://localhost:8081/Serv1, and my tomcat is running too. Then what's the problem?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pawan Arora wrote:Hi,






This DD(web.xml) must be related to some web app, so to access the servlet "Serv1", we need to provide relative path , i.e

something like this, http://localhost:8081/Your-Web_app-name/Serv1, try this..
 
Pawan Arora
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still not able to run servlet. This time I try to run it with the path http://localhost:8081/tomcat-docs/Ch1/Serv1 , but I'm still getting the same error. What's wrong now?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pawan Arora wrote:I still not able to run servlet. This time I try to run it with the path http://localhost:8081/tomcat-docs/Ch1/Serv1 , but I'm still getting the same error. What's wrong now?



Do you have servlet mapping entry for servlet url "Ch1/Serv1" in '/tomcat-docs/WEB-INF/web.xml' ?

And I don't understand why don't you create your sample web app, rather trying to run sevlet in any other app thats comes bundled with Tomcat.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you still face problems add this to your web.xml

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

and access your index.jsp by http://localhost:8081/webapplication name

start working from JSP ... like submiting to servelt .......

this can only serve as temporary solution for you to run a webpage ...

Sreedhar Siliveri
 
Saifuddin Merchant
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pawan Arora wrote:Hi,

my compiled servlet class is in class folder and as far as I concerned I've done mapping of servlet name correctly too. Here is the code



and I try to access it with an address http://localhost:8081/Serv1, and my tomcat is running too. Then what's the problem?




If your compiled files are in a folder called 'class' and not 'classes' then you are definitely doing something wrong.
To solve your problem a few details of exactly what you are doing would be helpful namely,

1. Are you able to see the Tomcat homepage when you type http://localhost:8081/ - This is a check that your server is working.

2. Did you modify the web-xml @ <Tomcat-Home>/webapps/tomcat-docs/WEB-INF/web.xml or are you placing your web-xml at some other location?

3. Are you class files present in the correct package in the folder <Tomcat-Home>/webapps/tomcat-docs/WEB-INF/classes or in some other location?

4. If all else fails do this,
a. Create a folder @ <Tomcat-Home>/webapps/Ch1.
b. Create a folder @<Tomcat-Home>/webapps/Ch1/WEB-INF.
b. Create a folder @<Tomcat-Home>/webapps/Ch1/WEB-INF/classes.
c. Copy the web.xml to the folder <Tomcat-Home>/webapps/Ch1/WEB-INF/classes. Your current web.xml is incorrect. The line <servlet-class>class/Ch1Servlet</servlet-class> should be <servlet-class>Ch1Servlet</servlet-class>. Do not for the time being put the Ch1Servlet in any package.
d. Copy the class file for Ch1Servlet to <Tomcat-Home>/webapps/Ch1/WEB-INF/classes.
e. Hit the link http://localhost:8081/Ch1/Serv1 in your browser to see if your servlet works!
f. Try doing a search on goolge on how to deploy a simple web application in tomcat !

If it still does not work, please upload screen shots of what you are doing --> The link you hit in the browser and the location where you have deployed your files in tomcat. This would really help to zero down on whats going wrong quicker!

Patience is the key – deploying your first web app is always hard and can be nerve racking. Once you get the hang of it – it will be easy as breeze!
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic