This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet configuration problem

 
Yichuan Wang
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Lave Kulshreshtha
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Hui Zhao
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic