Dear all,
this is my first servlet. simple and short. compiled without error. But failed when called.
file content::
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class prt extends HttpServlet
{
public void doGet (HttpServletRequest request,
HttpServletResponse response)
{
try{
PrintWriter out=null;
out = response.getWriter();
out.print("<HTML><HEAD><TITLE>"
out.print("</TITLE></HEAD><BODY>"
out.print("<H1>Hi</H1>"
out.print("<P>This is the line"
out.print("</BODY></HTML>"
}catch (Exception e)
{
System.out.println("Err:" + e.getMessage());
}
}
public void doPost (HttpServletRequest request,
HttpServletResponse response)
{
try{
PrintWriter out=null;
out = response.getWriter();
out.print("<HTML><HEAD><TITLE>"
out.print("</TITLE></HEAD><BODY>"
out.print("<H1>Hi</H1>"
out.print("<P>This is the line."
out.print("</BODY></HTML>"
}catch (Exception e)
{
System.out.println("Err: " + e.getMessage());
}
}
}
error::
java.lang.NullPointerException
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(Unknown Source)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java, Compiled Code)
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, Compiled Code)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
at java.lang.Thread.run(Unknown Source)
What could be wrong? Java is platform indepedent and jdk used is ver1.2.2. Wrong coding? Please kindly advise.
this is my first servlet. simple and short. compiled without error. But failed when called.
file content::
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class prt extends HttpServlet
{
public void doGet (HttpServletRequest request,
HttpServletResponse response)
{
try{
PrintWriter out=null;
out = response.getWriter();
out.print("<HTML><HEAD><TITLE>"
out.print("</TITLE></HEAD><BODY>"
out.print("<H1>Hi</H1>"
out.print("<P>This is the line"
out.print("</BODY></HTML>"
}catch (Exception e)
{
System.out.println("Err:" + e.getMessage());
}
}
public void doPost (HttpServletRequest request,
HttpServletResponse response)
{
try{
PrintWriter out=null;
out = response.getWriter();
out.print("<HTML><HEAD><TITLE>"
out.print("</TITLE></HEAD><BODY>"
out.print("<H1>Hi</H1>"
out.print("<P>This is the line."
out.print("</BODY></HTML>"
}catch (Exception e)
{
System.out.println("Err: " + e.getMessage());
}
}
}
error::
java.lang.NullPointerException
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(Unknown Source)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java, Compiled Code)
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, Compiled Code)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
at java.lang.Thread.run(Unknown Source)
What could be wrong? Java is platform indepedent and jdk used is ver1.2.2. Wrong coding? Please kindly advise.