This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with Tomcat

 
Claudio Donat�
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is Test.do type archive?
i suppose Test.do is just a url name.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Claudio Donat�
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the code to my servlet.



This is the Listener code.

 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Should be:
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One lesson here is not to say "all is ok" when something is not working
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic