File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Problems with Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems with Tomcat" Watch "Problems with Tomcat" New topic
Author

Problems with Tomcat

Claudio Donat�
Greenhorn

Joined: Dec 02, 2006
Posts: 7
People, when I put this path "http://localhost:8080/Beer-v1/Test.do" into my web browser instead of going to the servlet and creating a html page, the browser starts downloading of a Test.do type archive.

All my classes are ok and my web.xml is like this:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>Teste</servlet-name>
<servlet-class>com.example.ListenerTester</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Teste</servlet-name>
<url-pattern>/Test.do</url-pattern>
</servlet-mapping>

<context-param>
<param-name>breed</param-name>
<param-value>Beagle</param-value>
</context-param>

<listener>
<listener-class>
com.example.MyServletContextListener
</listener-class>
</listener>
</web-app>



Anyone knows what the problem is and how to fix it?

Thanks for the help.

Claudio
[ December 06, 2006: Message edited by: Claudio Donat� ]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
what is Test.do type archive?
i suppose Test.do is just a url name.


Rahul Bhattacharjee
LinkedIn - Blog
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Claudio Donat�:

All my classes are ok and my web.xml is like this:

How do you know they're all OK?

What URL are you using when trying to access your servlet?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Claudio Donat�
Greenhorn

Joined: Dec 02, 2006
Posts: 7
Rahul Bhattacharjee, Test.do is the name that I put on my web.xml archive to be the reference that the client uses to call the servlet. Like this:
<url-pattern>/Test.do</url-pattern>.

Ben Souther, I suppose my classes are ok because I copy them from the book Head first, Servlets and JSP. I check more than 1 time to see if I made a mistake there. The url that I am using is "http://localhost:8080/Beer-v1/Test.do", and it is the url that the book tell us to use.

Thanks for the reply people. I hope we can find out what I doing wrong.
Claudio Donat�
Greenhorn

Joined: Dec 02, 2006
Posts: 7
This is the message that I am getting when I try to access the servlet:


[ December 07, 2006: Message edited by: Claudio Donat� ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It looks to me that your class is not alright.

Post the code to your servlet.
When doing so, be sure to wrap the code in UBB Code tags (there is a button on the edit screen to help with this.
Claudio Donat�
Greenhorn

Joined: Dec 02, 2006
Posts: 7
This is the code to my servlet.



This is the Listener code.

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Not very sure , but are you having any file named Test.do in webapp/Beer-v1 folder in tomcat ?
What happends when you say yes to download?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



Should be:
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

One lesson here is not to say "all is ok" when something is not working


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with Tomcat