|
Hi,
When I make any changes to the code, I don't stop/start the
server but do need to close/restart the explorer. The refresh did not
work. And, yes, when I have classes in
c:\jakarta\webapps\root\web-inf\classes, it works. Now the source
codes...
package test;
import javax.servlet.*; import
javax.servlet.http.*;
public class ServletUtil { public static final
String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0
Transitional//EN\">\n";
public static String getHeadWithTitle(String
title) {
return (docType +
"<html>\n<head><title>" + title +
"</title></head>\n"); } }
package test;
import java.io.*; import javax.servlet.*; import
javax.servlet.http.*;
public class HelloWorld extends
HttpServlet { public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException { response.setContentType("text/html"); String
forHTML = ServletUtil.getHeadWithTitle("New Title") +
"<body><h1>Hello World using
methods</h1></body>\n</html>"; PrintWriter out
=
response.getWriter(); out.println(forHTML); } }
Thanks, June
----- Original Message -----
Sent: Wednesday, August 08, 2001 10:36
PM
Subject: Re: running servlet in
package
G'Day
June,
Just
curious...Is the servlet reloadable ? I have used the JSWDK(where servlets are
not reloadable), and when I add a new servlet, or change code, I have to
stop/start the server for the class to be recognized. I'm sure apache
allows servlet reloading, but I'm wondering if it needs to be
defined.
Since localhost/servlet/HelloWorld works, I assume you have the class also in
c:\jakarta\webapps\root\web-inf\classes
Can you also post the source code
?...
Thanks
Bill
-----Original Message----- From: June
[mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 08, 2001 4:20
AM To: [EMAIL PROTECTED] Subject:
running servlet in package
I am reading Core Servlets and JSP and
trying to run a servlet in a package. I have put "package test; " in the
source code and compiled it in the dos using javac -d
c:\jakarta\webapps\root\web- inf\classes HelloWorld.java with no
problem. After running that command, I have this class file in the
c:\jakarta\webapps\root\web-inf\classes\test. However, when I
type "localhost/servlet/test.HelloWorld" in the explorer, I get the
following error.
Internal Servlet
Error:
java.lang.NullPointerException at
java.lang.ClassLoader.resolveClass0(Native Method) at
java.lang.ClassLoader.resolveClass(ClassLoader.java:588) at
org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:430) at
org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader.java:174) at
org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265) at
org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289) at
org.apache.tomcat.core.Handler.service(Handler.java:254) at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797) at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166) at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) at
java.lang.Thread.run(Thread.java:484)
Please tell me what I am doing
wrong. The Apache server and the tomcat are running just fine, because I
can run this servlet(without the package statement) by typing
localhost/servlet/HelloWorld with no problem.
Cheers,
June
___________________________________________________________________________ To
unsubscribe, send email to [EMAIL PROTECTED] and include in
the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources:
http://java.sun.com/products/servlet/external-resources.html LISTSERV
Help: http://www.lsoft.com/manuals/user/user.html
|