• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Compilation

 
Suja Mudunuri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am reading HF Servlets & JSP book. I am on the exercise at page 81. I am unable to compile the servlet. Compiler is unable to find javax.servlet.* package. I also set the CLASSPATH in environment variables(C:\jakarta-tomcat-5.5.5\common\lib . Can someone help me. What do I need to do to resolve this error?

Regards.
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did u give the full path to the end...the classpath doesn't end with /lib/ .You should also include the remaining path..the jar file...that 2 lines is one whole command.
try it...
 
Suja Mudunuri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ThankYou, I added servlet-api.jar in the CLASSPATH and it worked.

Regards
[ January 27, 2005: Message edited by: Suja Mudunuri ]
 
Suja Mudunuri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have one more problem can U Please help me. This is the same exercise on page 81. I have my class file, HTML and web.xml in place. I am trying to run the app. I am able to see the form.html but when I click on submit query, I get this error(HTTP Status 405-HTTP method POST is not supported by this URL. I am not able to understand what I did wrong.
http://localhost:8080/Beer-v1/SelectBeer.do

type Status report

message HTTP method POST is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).
 
Prasad Pusapati
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suja,
I Think...In HTML You Are Using POST And In Servlet Source File You Are Using doGet().That Is The Reason You Are Getting The Error.Make Sure The action Attribute Value In HTMl Must Match With Corresponding doXXX() In Servlet.
Bye.
Prasad Pusapati.
 
Suja Mudunuri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prasad,
I had a typo for dopost() instead of doPost()
Now I am getting this error. It is not able to see the class file. The actual path of the class file is C:\jakarta-tomcat-5.5.5\webapps\Beer-v1\WEB-INF\classes\com\example\web

HTTP Status 404 - /Beer-v1/com/example/web/BeerSelect

type Status report

message /Beer-v1/com/example/web/BeerSelect

description The requested resource (/Beer-v1/com/example/web/BeerSelect) is not available.


This is my web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>

I am not able to see what I am doing wrong. Please help.
[ January 28, 2005: Message edited by: Suja Mudunuri ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic