This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes GenericServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "GenericServlet" Watch "GenericServlet" New topic
Author

GenericServlet

Jeffrey Pony
Greenhorn

Joined: Jun 24, 2002
Posts: 25
GenericServlet implements Servlet and ServletConfig.
I am however getting the following exception..

generic.java:19: cannot resolve symbol
symbol : method getServletName ()
location: interface javax.servlet.ServletConfig
String ss = servletConfig.getServletName();
Code is :
public class generic extends GenericServlet
{
public void service(ServletRequest request, ServletResponse response)throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
ServletConfig servletConfig = getServletConfig();
String ss = servletConfig.getServletName();
pw.println(".."+ss);
}
}
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
Hi Jeffrey
I ran your code asis and had no problems. It compiled ok and, when run, returned "..generic".
Are there any other bits to your code that you can show us?
Mark.
Jamie Shi
Ranch Hand

Joined: Oct 01, 2002
Posts: 46
Hi Jeffrey,
I think you didnot add Servlet.jar into your CLASSPATH.
Jeffrey Pony
Greenhorn

Joined: Jun 24, 2002
Posts: 25
I accept that its a strange problem but it is finding GenericServlet, ServletRequest,ServletResponse, ServletConfig also..so it is finding servlet.jar from the classpath.
Iam using tomcat from the Cd that comes along with hanumant's book and jdk1.3.I guess that the version is tomcat 4.0.
Mark : Couple of more lines but those were pw.printlns which seemed fine !!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: GenericServlet
 
Similar Threads
init() method doubt?
frank help!!again
Regarding init parameters
get a servlet name
getServletContext() and getServletName()