make mistake in using XML to deploy web application archive file

C

cong

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<display-name>ShowLifecycles</display-name>
<description>An example of how to use lifecycle events</
description>

<listener>
<listener-class>
examples.MyAppListener
</listener-class>
</listener>
</web-app>

ShowLifecycles.jsp:
<html>
<body>

<%!
public void jspInit()
{
log("***ShowLifecycles.jsp - Invoked jspInit()");
}
%>
<%!
public void jspDestroy()
{
log("***ShowLifecycles.jsp - Invoked jspDestroy()");
}
%>

log("***ShowLifecycles.jsp - Invoked jspService()");
%>

The current date is: <%= new java.util.Date() %>
</body>
</html>

MyAppListener:java
package examples;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class MyAppListener
implements ServletContextListener {

public void contextInitialized(ServletContextEvent event) {
ServletContext context = event.getServletContext();
context.log("***ShowLifecycles - Created the servlet
context");
}

public void contextDestroyed(ServletContextEvent event) {
ServletContext context = event.getServletContext();
context.log("***ShowLifecycles - Destroyed the servlet
context");
}
}

error information following:
org.xml.SAXparseException
the processing instruction target match "[xX][mM][lL]" is not allowed

how can I fix it?
 
J

Joe Kesselman

error information following:
org.xml.SAXparseException
the processing instruction target match "[xX][mM][lL]" is not allowed

how can I fix it?

The XML declaration MUST be the very first thing in the file, except for
the optional byte-order mark. Remove the whitespace preceding it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top