• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Wrapper cannot find servlet class

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!!

I am new to servlets. I am trying to run an example from head first servlets(page 81). I have copied BeerSelect.class froma different location. Rest all is same as it says in the book.

Errors I am getting are

javax.servlet.ServletException: Wrapper cannot find servlet class com.example.web.BeerSelect or a class it depends on


java.lang.ClassNotFoundException: com.example.web.BeerSelect



Please help!!

Surbhi
 
surbhi tugnawat
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I Start Tomcat by clicking start button on the Apache tomcat property window. Is it the right way of starting it???
http://localhost:8080 runs fine.

As I mentioned earlier I am having difficulties running the example in chapter 3 . I have my exapmle(Beer) in c:Tomcat/webapps/Beer

There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web.

When I run Tomcat I can open the form.html. This form instead of "Submit" button displays "Submit query"( Dont know why)
and when I pick the color from drop down and hit Submit query button.. i get Http Status 500 and above mentioned erros.

So thats my problem.
HELP!!!
Surbhi
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web

You mean you have BeerSelect.class in com/example/web don't you.

Don't worry about the 'Submit Query' thing, it's a HTML problem and not related to your issue. We can fix that later.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by surbhi tugnawat:
[QB]There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web.



Just wanted to ensure that it is down the three folder hierarchy com, example and web and not a single folder names com.eaxmple.web !

Also, the class should have the matching package declaration in the code..so do you have a package com.example.web; in the source code ?
 
Manzar Zaidi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by surbhi tugnawat:
[QB]There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web.



Just wanted to ensure that it is down the three folder hierarchy com, example and web and not a single folder names com.eaxmple.web !

Also, the class should have the matching package declaration in the code..so do you have a package com.example.web; in the source code ?
 
surbhi tugnawat
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes BeerSelect.class is in WEB-INF/classes/com/example/web...and I also have the package statement in it.
 
Manzar Zaidi
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by surbhi tugnawat:
javax.servlet.ServletException: Wrapper cannot find servlet class com.example.web.BeerSelect or a class it depends on



or a class it depends on
When you have the package set up properly and mapped correctly, it time we have to get into the code. Could you pleae paste the servlet code ?
And ... or a class it depends on..Please ensure that you have all the required libraries in the web-inf/lib folder.

The "Submit query" is the default message that shows up on submit button if you dont give it a name, so maybe your name element is missing or spelt wrong.
 
surbhi tugnawat
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Here is my Servlet code

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException{

response.setContentType("text.html");
PrintWriter out =response.getWriter();
out.println("Beer selection advice <br>");
String c=request.getParameter("color");
out.println("<br> Got beer color " + c);

}
}
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic