This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes problem with web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem with web.xml" Watch "problem with web.xml" New topic
Author

problem with web.xml

Andrew McLaren
Ranch Hand

Joined: May 27, 2005
Posts: 33
Let me preface this by saying I am pretty new to the world of servlets and jsps.

I've got a little application set up, and it's been working so far. I've added another class that I want to be able to call from a jsp. I've added it to my web.xml, and now when I try to open my first page, I get a 404 from tomcat. If I take out the servlet and servlet mapping for the second servlet (CRNListObjects), it works fine.

Here's my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>CRNSignon</servlet-name>
<servlet-class>com.crn.hcsc.CRNSignon</servlet-class>
</servlet>

<servlet>
<servlet-name>CRNListObjects></servlet-name>
<servlet-class>com.crn.hcsc.CRNListObjects</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>CRNSignon</servlet-name>
<url-pattern>/Logon.do</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>CRNListObjects</servlet-name>
<url-pattern>ListObjects.do</url-pattern>
</servlet-mapping>

<display-name>crn</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

What am I doing wrong?

Thanks

Andrew
Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
Hi, If u have copied the web.xml and pasted it as is in this
forum, then probably.
check the > in your servlet-name tag (second servlet).

I Hope this helps.


SCJP2, SCWCD
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I've added another class that I want to be able to call from a jsp.


Is that class a servlet?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Andrew McLaren
Ranch Hand

Joined: May 27, 2005
Posts: 33

Hi, If u have copied the web.xml and pasted it as is in this
forum, then probably.
check the > in your servlet-name tag (second servlet).


Dang, I thought that was it! I fixed that, but I get the same result.

Originally posted by Ben Souther:


Is that class a servlet?


Yes it is.
[ May 28, 2005: Message edited by: Andrew McLaren ]
sergio mendez-rueda
Ranch Hand

Joined: May 12, 2005
Posts: 37

<servlet-mapping>
<servlet-name>CRNListObjects</servlet-name>
<url-pattern>ListObjects.do</url-pattern>
</servlet-mapping>
W


right:
<servlet-mapping>
<servlet-name>CRNListObjects</servlet-name>
<url-pattern>/ListObjects.do</url-pattern>
</servlet-mapping>

in the lt;url-pattern>/BlaBla.do</url-pattern>
don't forget the slash / !!!
gruesse
ser
Andrew McLaren
Ranch Hand

Joined: May 27, 2005
Posts: 33
Originally posted by sergio mendez-rueda:


right:
<servlet-mapping>
<servlet-name>CRNListObjects</servlet-name>
<url-pattern>/ListObjects.do</url-pattern>
</servlet-mapping>

in the lt;url-pattern>/BlaBla.do</url-pattern>
don't forget the slash / !!!
gruesse
ser



Hooray!

Two stupid mistakes in one morning! Teach me to try and learn some stuff on a weekend Thanks!

Peace

Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with web.xml