Hi,
I am
testing the code in the book "Java Developer's guide to servelt and JSP" the part of
Applet and
Servlet communication.
I am using JBuilder and I am totally lost what's wrong with my setting and I keep getting the error message. Pls help me with it. Thank you so much!
This is the exact code in this book.
package test515;
import com.javaranch.common.*;
// I use the package in Javaranch
// You can find it in this website
// And ObjectServlet is a servlet class in
// that package
class PipelineServlet extends ObjectServlet{
public Object doObject(Object obj){
String old = (String)obj;
String s = "";
for(int i = old.length() -1;i>=0; i--){
s+= old.charAt(i);
}
return s;
}
}
What I do is set up a project and import the com.javaranch.common package inthis project. And then use servlet wizard to write a servlet as above. The only difference is that it extends ObjectServlet instead of HttpServlet
Here is the web.xml
I think maybe there's something wrong with this
But i don't know what's it.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>pipelineservlet</servlet-name>
<servlet-class>test515.PipelineServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>pipelineservlet</servlet-name>
<url-pattern>/pipelineservlet</url-pattern>
</servlet-mapping>
</web-app>
The error message is like
Error: 500 Location: /pipelineservletInternal Servlet Error:java.lang.IllegalAccessException: test515.PipelineServlet
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:268)
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.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Thank you in advance!
Calanthe