jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Servlet and XML file.. 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 "Servlet and XML file.." Watch "Servlet and XML file.." New topic
Author

Servlet and XML file..

Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
Hi,
I created a xml file (web.xml) which is given below as shown in the book
******************************************************
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>
ShowMsg
</servlet-name>

<servlet-class>
coreservlets.ShowMessage
</servlet-class>

<init-param>
<param-name>
message
</param-name>
<param-value>
Chakravarthy
</param-value>
</init-param>

<init-param>
<param-name>
repeats
</param-name>
<param-value>
5
</param-value>
</init-param>
</servlet>
</web-app>
**************************************************
I am trying to use the elements in here in a servlet. This is an example that I trying a book ( Coreservlets and JSP by Marty Hall). When I put this web.xml in the d:\resin1.2.1\doc\web-inf directory and start the resin server, it gives me a error saying...
CANNOT MIX TEXT AND ELEMENTS AT WEB-APP followed by a bunch of exceptions.
I do not know any XML and I just started learning servlets..
Could somebody help me?
Chuck
Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Hi, I don't know much about resin, but most servers have a webapps directory(for Web Applications) then under it there are the application directories (usually the name of the application, like MyCatalog) under the application directories there are the Web-inf directories. And then classes and lib such. Maybe you can try tomcat if you really can't get resin to work.
[This message has been edited by Bob Moranski (edited December 22, 2000).]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
It looks to me like it is objecting to something about the formatting in the web.xml file. You need to find an XML checking utility to make sure it is well formed. Unfortunately, the one I use (Clip) seems to have gone out of business!
You might try closing up the tags like this:
<init-param><param-name>message</param-name>
<param-value>Chakravarthy</param-value>
</init-param>
just in case the server is not trimming blanks from the values.
(just a guess)
Bill

------------------
author of:
 
wood burning stoves
 
subject: Servlet and XML file..