• Post Reply Bookmark Topic Watch Topic
  • New Topic

puzzled with servlet issues  RSS feed

 
Nassia Papasaras
Greenhorn
Posts: 7
MySQL Database Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I'm using netbeans IDE 8.0.2, Tomcat 8.0.9.0, MySQL 5.6 and I've written the following Servlet (Search1.java):



that I access from a jsp page using the following command:



but when I try to run it, basically when I enter a keyword and click search, the browser goes to http://localhost:8084/Search1 and shows nothing.
I'm really puzzled as to why it does it, but since I'm new to jsps and servlets it could be really simple.

Here is my web.xml that I believe I've configured correctly:



and my file configuration, hoping it could help

Please help!
 
Stefan Evans
Bartender
Posts: 1834
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So all you're getting is a blank page?
What are you expecting to see?
Why would it not forward to that JSP file?
Most probably a SQLException is occurring. In the case of an Exception you are just logging the stacktrace and exiting. No feedback is sent to the web page.

To confirm this check the console log for error messages.
Alternatively just let it throw the exception (don't catch and swallow) and Tomcat should show you an error page that can help you debug.

 
Nassia Papasaras
Greenhorn
Posts: 7
MySQL Database Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:So all you're getting is a blank page?
What are you expecting to see?
Why would it not forward to that JSP file?
Most probably a SQLException is occurring. In the case of an Exception you are just logging the stacktrace and exiting. No feedback is sent to the web page.

To confirm this check the console log for error messages.
Alternatively just let it throw the exception (don't catch and swallow) and Tomcat should show you an error page that can help you debug.



You are right. Tomcat log shows that it can't find the java class:
SEVERE [http-nio-8084-exec-22] org.apache.catalina.core.StandardContext.loadOnStartup Servlet threw load() exception
java.lang.ClassNotFoundException: ergasia
The thing is that "ergasia" is the package in which I have placed my Servlet, (Search1.java) and the class is "Search1".
 
Nassia Papasaras
Greenhorn
Posts: 7
MySQL Database Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed this: from this in web.xml as it wouldn't run and say that it can't find the ergasia class (ergasia is the package in which I have the Search1 class), and now tomcat can't find my class, Search1.
How can I make it "see" that it's inside the "ergasia" package, without mistaking ergasia for a class?
 
Stefan Evans
Bartender
Posts: 1834
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You had the right servlet-class setting before.
is what it should be based on the information you have provided thus far.


Can you provide a bit more of the error message?
Is there a another reference to "ergasia" elsewhere that might cause this?

I would suggest cutting back your servlet to be a simple "Hello World" and get that configured and working
Once you have a simple servlet working (and you know your web.xml is good) then start adding the database code in.

 
Nassia Papasaras
Greenhorn
Posts: 7
MySQL Database Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:Is there a another reference to "ergasia" elsewhere that might cause this?


Yes! That was it, my database has the same name, I didn't know that it could cause a conflict.
Now it works just fine!
Thank you!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!