• 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

servlet configuration problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone, I am new to this forum.
I come across a problem when I was doing the example from "Head First Servlet and JSP"(page 30-31).

I wrote a Servlet (HelloWorldTest), compiled it (no error) and placed it
in :I:\Web\Tomcat 6.0\webapps\ROOT\Test\WEB-INF\classes
THe WEB-INF file is placed
in: I:\Web\Tomcat 6.0\webapps\ROOT\Test\WEB-INF

When I tried to access the servlet using:
http://localhost/Test/hello
got the following message
Not Found

The requested URL /Test/hello was not found on this server.


Servlet File:


Here is my WEB-INF file:

Anybody can tell me what is wrong with my code??
thanks very much
[ January 19, 2008: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I:\Web\Tomcat 6.0\webapps\ROOT\Test\WEB-INF\classes


Please move your application under webapps, not under ROOT :
I:\Web\Tomcat 6.0\webapps\Test\WEB-INF\classes

Also, you'll probably have to access Tomcat at port 8080 :
http://localhost:8080/Test/hello
 
Yichuan Wang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Christophe Verre:

Please move your application under webapps, not under ROOT :
I:\Web\Tomcat 6.0\webapps\Test\WEB-INF\classes

Also, you'll probably have to access Tomcat at port 8080 :
http://localhost:8080/Test/hello



Thanks for your reply,
first, can you please tell me why should I move it to webapp directory?
isn't the ROOT directory supposed to be the default directory for WWW access??

I use both apache and Tomcat for WWW accessing on my machine, where
Apache is for rendering static html, Tomcat is for JSP and servlets.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yichuan Wang:

isn't the ROOT directory supposed to be the default directory for WWW access??


No, webapps is.
 
Yichuan Wang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Christophe Verre:

Please move your application under webapps, not under ROOT :
I:\Web\Tomcat 6.0\webapps\Test\WEB-INF\classes

Also, you'll probably have to access Tomcat at port 8080 :
http://localhost:8080/Test/hello



I tried it in your way, and it works,
but I've got a new question:it works when I use
http://localhost:8080/Test/hello
but if use http://localhost/Test/hello, then the error message
pops up again.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Every application server has dedicated ports for various kinds of services.
In your case 8080 is the default port which is used to access www application.

-Lave

Originally posted by Yichuan Wang:


I tried it in your way, and it works,
but I've got a new question:it works when I use
http://localhost:8080/Test/hello
but if use http://localhost/Test/hello, then the error message
pops up again.

 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yichuan Wang:


I tried it in your way, and it works,
but I've got a new question:it works when I use
http://localhost:8080/Test/hello
but if use http://localhost/Test/hello, then the error message
pops up again.





The default port for non-secure HTTP is 80.
If you don't specify a port the browser will automatically use port 80.

For a couple reasons, Tomcat ships with its default port set to 8080.
You can change it by editing your tomcat/conf/server.xml file.
Look for the <Connector ... /> entry that its port attribute set to 8080 and change it to 80. Restart Tomcat and you can use the URL that you mentioned.
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Removed hi-jack]

Hui Zhao,
It is better to ask your question in a new thread than to potentially hijack this one with a similar but different question.
[ January 20, 2008: Message edited by: Ben Souther ]
 
Yichuan Wang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:




The default port for non-secure HTTP is 80.
If you don't specify a port the browser will automatically use port 80.

For a couple reasons, Tomcat ships with its default port set to 8080.
You can change it by editing your tomcat/conf/server.xml file.
Look for the <Connector ... /> entry that its port attribute set to 8080 and change it to 80. Restart Tomcat and you can use the URL that you mentioned.


Hi Ben, thanks for your reply,
I think now I found out why http://localhost:8080/Test/hello works where http://localhost/Test/hello doesn't. but I still don't know how to fix it yet. The reason for why port 80 doesn't work is because Apache can not handles Servlet properly. It appears that it can properly handles JSP and Do files but not Servlets, there could be something wrong with the configuration of the helper program(Jakarta Tomcat connector).
I have both Tomcat and Apache installed on my desktop, an additional helper
software(Jakarta Tomcat connecter) is also installed which connects Apache with Tomcat.
When there is a static html page, apache handles it, and when there is a JSP page apache passes it over to Tomcat.


When I use port 80(Apache):
It works perfectly when it processes JSP pages, but it just can not process servlets.

This is the configuration I added to Apache httpd.conf


anybody could possibly tell me why?
or should I change line:JkMount /servlet/* ajp13
to something else?
[ January 20, 2008: Message edited by: Yichuan Wang ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using something more than just Tomcat, it's a good idea to mention that upfront. I didn't know that you were connecting Tomcat to the Apache Web Server till now.


These days, I use Tomcat as a standalone so I'm out of practice when it comes to connecting it to other web servers.

Maybe someone else can assist you in getting the two to cooperate.
 
Yichuan Wang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
If you're using something more than just Tomcat, it's a good idea to mention that upfront. I didn't know that you were connecting Tomcat to the Apache Web Server till now.


These days, I use Tomcat as a standalone so I'm out of practice when it comes to connecting it to other web servers.

Maybe someone else can assist you in getting the two to cooperate.



Sorry about the confusion, I should have mentioned that at the very beginning, but I did not know this was the cause of the problem.

hope somebody else could know more about the problem.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to move this to our Apache / Tomcat forum.

The forum covers Tomcat more than the Apache Web Server but someone there might be able to help you with the connector configuration.
 
Yichuan Wang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
I'm going to move this to our Apache / Tomcat forum.

The forum covers Tomcat more than the Apache Web Server but someone there might be able to help you with the connector configuration.



Yes please, and I desperately need answers
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic