aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes I really stuck and need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "I really stuck and need help " Watch "I really stuck and need help " New topic
Author

I really stuck and need help

Dean Fredericks
Ranch Hand

Joined: Dec 04, 2004
Posts: 60
Hi guys

I cant get the first example program for the head first book to work.
I can deploy the html form and access that. But when I click "Submit", which is ment to send data the the servlet - nothing happens.

What must I do? I dont know what the problem is - i dont know how to find out what the problem is. I look at the XML discriptor and it looks right, i look at the html and it looks right, i look at the servlet and it looks right. When i run tomcats examples they work.

What must i do to find out what the problem is. Where must I look, how do i diagnose this ?

If you have any advice for me Id greatly apricate it.

Thanks guys!


PLEASE WATCH THIS VIDEO: <a href="http://www.glumbert.com/media/dolphin" target="_blank" rel="nofollow">http://www.glumbert.com/media/dolphin</a><br /> <br /><-- that video is no joke. Spread the word... this cant go on!!!<br /> <br />SCJP 1.4, SCBCD 1.3, SCWCD 1.4, SCMAD 1.0
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
Post your html from the example so we can give suggestions. If nothing at all happens, my guess would be that the action on your form is not correct... but that is just a guess until I can see your code.


“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Dean Fredericks
Ranch Hand

Joined: Dec 04, 2004
Posts: 60
Thanks for showing interest in my problem

here is the HTML code in "form.html"
-------------------
<html><body>
<h1 align="center">Beer Selection Page</h1>
<form method ="POST'
action = "SelectBeer.do">
Select beer characteristics<p>
color:
<select name="color" size="1">
<option>light
<option>dark
<option>brown
<option>amber
</select>
<br><br>
<center>
<input type="SUBMIT">
</center>
</form></body></html>
-----------------------------------------
here is the code from the xml descriptor
-----------------------------------------
<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.wsd"
version="2.4">

<servlet>
<servlet-name>Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>
----------------------------------------------
Here is the code in the servlet
-----------------------------------
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 responce) throws
IOException, ServletException
{

responce.setContentType("text/html");
PrintWriter out = responce.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got Bee color" + c);
}

}
---------------------------------------


How it is possible to diagnose errors ? how do u know if u have an error with tomcat, your xml descriptor, ur html, or ur servlet ???
janne s
Ranch Hand

Joined: Sep 21, 2004
Posts: 81
Hi!,

I'm also preparing for exam. I tried your example its running...

I'm using Eclipse

did u try running the appl again ?


jaya
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
I don't see any problems with your code. Have you tried restarting Tomcat?
Dark Moon
Greenhorn

Joined: Aug 03, 2003
Posts: 5
i`m facing the same problem too !!
thanx
Dark Moon
Greenhorn

Joined: Aug 03, 2003
Posts: 5
i`m using jakarta-tomcat-5.0.29
and i got this 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 allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)


root cause

java.lang.UnsupportedClassVersionError: com/chapter03/beerexamplev01/web/BeerSelect (Unsupported major.minor version 49.0)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:537)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)
kasun madurasinghe
Greenhorn

Joined: Sep 16, 2004
Posts: 4
There's nothing wrong with the code . Can u see tomcat's welcome page? (The page u see when u type http://localhost:8080 or http://ip_address:8080)

------------------------------------------------------------------------
"There is no spoon" - Alia Neo
[ January 07, 2005: Message edited by: kasun madurasinghe ]
Dark Moon
Greenhorn

Joined: Aug 03, 2003
Posts: 5
Hey guys , sorry for interruption but I finally found what makes me solve my problem which is the same (as I think) to the original form question , regarding that every thing is very well ur servlet web.xml form.html and ur configuration also !!
This link gave me a hint what the solution can be
http://forum.java.sun.com/thread.jspa?threadID=562771&tstart=75
I made the JAVA_HOME use the same JDK i used to develop the servlet
And finally it worked
I used 1.5 to develop the servlet
When I was testing the tomcat JAVA_HOME was 1.4.2_03

Btw: Any idea why this happen?

I hope it may help any one out there 
Dean Fredericks
Ranch Hand

Joined: Dec 04, 2004
Posts: 60
My thing still doesnt work.

What sorta of a java programmer will I make If I cant even get a small servlet to display !
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
1. What are your environment variables?
(a.) check JAVA_HOME (should be 1.4x, for Tomcat 5.029)

2. As someone else pointed out, check if you can get Tomcat itself to work.

3. Assuming Tomcat works, then try to see if some of the JSP samples and Servlet samples are working.

4. Did you compile your servlet code using J2SDK 1.4x compiler?
Tim Hanbey
Greenhorn

Joined: Jan 11, 2005
Posts: 1
I had the same exact problem, check your Web.xml. It may not be well-formed. If there is some sort of problem with the web.xml Tomcat will throw an error at you when it trys to build a context. It will be continue to start up, but check the logs...

I copied one of the web.xml 's from the examples provided with Apache Tomcat.

This should give you a good start to looking though, because as the guy above said, there isn't anything wrong with the code itself, just make sure the xml is well formed.

Hope this helps, btw, I'm new, going through the book as well and this is my first posting.

-Tim
Deepa Rao
Greenhorn

Joined: Jun 30, 2004
Posts: 6
Better check these small things---

The java class file placed in the Web-inf/classes directory
The form.html in the application root directory
The servlet & servlet mapping tags in the web.xml file be placed in order...since the servlet tags comes first THEN the servlet-mapping tags. If u have put any other servlet then put all the servlet tags first then all the servlet-mapping tags matching(in revesre order)

reply if not clear...or if its solved
Dean Fredericks
Ranch Hand

Joined: Dec 04, 2004
Posts: 60
The problem is line 3 of the HTML code - its a ' instead of a " - pity nobody could pick this up. Errors like this have demotivated me about JSP and servlet - since its taken my 2 weeks to find that error - and the error was LAME.
K Gupta
Ranch Hand

Joined: Aug 31, 2004
Posts: 43
I'm still getting the problem,although I had set JAVA_HOME to java 1.5 directory. I m using Tomcat 5.5.4 and it doesn't have /bin/startup.bat.
All the other examples are working just fine.
Please Help.


SCJWSD, SCBCD,SCWCD, SCJP
If I am destined to fail, then I do have a purpose in my life: To fail my destiny.
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
Is there a tomcat.sh or tomcat.exe? Try running that from a command line. Also ensure that you do not have any additional CLASSPATH and JAVA_HOME specified in your System Environment. You can easily find this out by going to the command prompt(cmd or any unix shell) and echoing these environment behavior.
K Gupta
Ranch Hand

Joined: Aug 31, 2004
Posts: 43
Yes there is tomcat5.exe and there are no other variable defined.
Wasim Ayoubi
Ranch Hand

Joined: Nov 21, 2004
Posts: 46
Hi there

I did not read all the replies posted, I just took a quick look.

I understand that you are using JDK1.5 to develop the Servlet class and it is deployed on tomcat server whatever version, using JDK1.4.2

JDK1.4.2 can not load a class compiled by JDK1.5 unless you specify -source 1.4

jdk1.5\bin> javac -source 1.4 MyServlet.java

try to tune your IDE to use JDK1.4.2 or use the -source option and you will be more than happy.
[ January 16, 2005: Message edited by: wasim ayoubi ]

Wasim Ayoubi<br />SCJA1.0(BETA), SCJP1.4, SCWCD1.4<br />Next ???
Stephen Galbraith
Ranch Hand

Joined: Oct 27, 2003
Posts: 90
Re: no bin/startup.bat.

I also have tomcat 5.5 and it does have a startup.bat (and a startup.sh) in the bin directory

Steve


SCJP 1.4, SCJD, SCWCD 1.4
K Gupta
Ranch Hand

Joined: Aug 31, 2004
Posts: 43
Try .zip version.It Works !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I really stuck and need help
 
Similar Threads
Error 404
What does this girl mean ?
URL-Pattern mappings must contain /servlet/?
blog of Kathy - Pair Programming is NOT always a choice
Some unanswered question in swings/awt/jfc????kindly answer me these questions??