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?
<?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?