My HTML file is as follows-
Below is DD .xml file -
Below is
servlet code -
I have followed the same instructions as in the book.
On running the above command on the command prompt i successfully got the CoffeeSelect.class file. But if someone can verify the above command and also help me understand the following part of the above command "C:\Tomcat 5.25\common\lib\servlet-api.jar";classes;. if it is right!
My Development Environment-
For HTML file is E:\MyProjects\coffeeV1\web\form.html
For DD file is E:\MyProjects\coffeeV1\etc\web.xml
For servlet file is E:\MyProjects\coffeeV1\src\com\example\web\CoffeeSelect.java
For servlet .class file is E:\MyProjects\coffeeV1\classes\com\example\web\CoffeeSelect.class
My Deployment Environment-
For HTML file is C:\Tomcat 5.25\webapps\Coffee-v1\form.html
For DD file is C:\Tomcat 5.25\webapps\Coffee-v1\WEB-INF\web.xml
For servlet .class file is C:\Tomcat 5.25\webapps\Coffee-v1\WEB-INF\classes\com\example\web\CoffeeSelect.class
On running the following URL on the Google Chrome browser -
http://localhost:8080/Coffee-v1/form.html
the form gets displayed but when i click the Submit button
i get the following error-
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Error instantiating servlet class com.example.web.CoffeeSelect
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Thread.java:619)
root cause
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.example.web.CoffeeSelect with modifiers ""
sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
java.lang.Class.newInstance0(Class.java:349)
java.lang.Class.newInstance(Class.java:308)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Thread.java:619)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.
Apache Tomcat/5.5.25
And if i reload the page i get -
HTTP Status 404 - Servlet Ch3 Coffee is not available
type Status report
message Servlet Ch3 Coffee is not available
description The requested resource (Servlet Ch3 Coffee is not available) is not available.
Apache Tomcat/5.5.25
One more thing guys do i have to download the javax package? But i did not find such reference in the book. I also tried doing that but still i cannot get he above error out of my sight!
Hey friends and all you knowledgeable people kindly help me out with my first servlet program and help me out from getting discouraged and loose interest over this as i have been doing various modifications but none seems to work out. Help me guys!