Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

problems with web.xml

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
I am trying to create my first web app servlet working in a folder- murach.It has an email form, which passes the parameters to a page using servlet. I am using Tomcat 5.5
I have placed web.xml in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\murach\WEB-INF\classes
I am also using the same web.xml as in the servlets-examples folder in Tomcat 5.5. I have made the following changes to my web.xml in order to get my application working. This hint I got from one of the forum discussions in JavaRanch.
<servlet>
<servlet-name>EmailServlet</servlet-name>
<servlet-class>email5.EmailServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EmailServlet</servlet-name>
<url-pattern>/servlet/email5/EmailServlet</url-pattern>
</servlet-mapping>
*******
Then, I put the Context tag in server.xml which is in C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf
My Context tag looks like this:
<Context path="/murach"
docBase="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\murach"
reloadable="true" debug="0"/>

Still, I am not able to run the servlet when I go through the html page, which is :
http://localhost:8080/murach/join_email_list.html
The moment I hit SUBMIT button, it shows
http://localhost:8080/servlet/email5.EmailServlet?firstName=kiran&lastName=kumar&emailAddress=kirankumar%40yahoo.com
in the address bar and says,
404 -FILE NOT FOUND ERROR

I am not able to figure out why is this showing like this. I would really appreciate if somebody could help me out with this!!
-Thanks
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have worked with tomcat a little bit...the URL mapping is wrong


Intead of <url-pattern>/servlet/email5/EmailServlet</url-pattern>
use <url-pattern>/EmailServlet</url-pattern>

Hope this may help you
 
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
You don't need to alter your server.xml file if your webapp is under the 'webapps' directory. Tocmat will take care of deploying it for you.

You also don't need to put "servlet/" in the url-mapping.
You can if you want to but it's not requires.
The use of 'servlet/..' was required back when the (now deprecated) invoker servlet was common in Tomcat apps.
 
rakhee vissa
Greenhorn
Posts: 4
  • 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:
You don't need to alter your server.xml file if your webapp is under the 'webapps' directory. Tocmat will take care of deploying it for you.

You also don't need to put "servlet/" in the url-mapping.
You can if you want to but it's not requires.
The use of 'servlet/..' was required back when the (now deprecated) invoker servlet was common in Tomcat apps.



Thank you.. I got it working!!
 
Whatever. Here's a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic