Forums Register Login

problems with web.xml

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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!!
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 967 times.
Similar Threads
Problem running simple Servlet on Tomcat
Head First Servlets and JSP - My first servlet Program is not running
HTTP Status 404 - /myApp/servlet/Testing
Perl/Cgi in Tomcat 5.5
Servlet not showing up in Browser
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:12:17.