Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My first servlet - failed

Status
Not open for further replies.

ITAppser

Technical User
Nov 12, 2001
3
SG
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(&quot;<HTML><HEAD><TITLE>&quot;);
out.print(&quot;</TITLE></HEAD><BODY>&quot;);
out.print(&quot;<H1>Hi</H1>&quot;);
out.print(&quot;<P>This is the line&quot;);
out.print(&quot;</BODY></HTML>&quot;);
}catch (Exception e)
{
System.out.println(&quot;Err:&quot; + e.getMessage());
}
}

public void doPost (HttpServletRequest request,
HttpServletResponse response)
{
try{
PrintWriter out=null;
out = response.getWriter();
out.print(&quot;<HTML><HEAD><TITLE>&quot;);
out.print(&quot;</TITLE></HEAD><BODY>&quot;);
out.print(&quot;<H1>Hi</H1>&quot;);
out.print(&quot;<P>This is the line.&quot;);
out.print(&quot;</BODY></HTML>&quot;);
}catch (Exception e)
{
System.out.println(&quot;Err: &quot; + 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.
 
How have you deployed the servlet to Tomcat and how are you calling it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top